Jump to content

Recommended Posts

Here's a funny thing.

Load the attached RGB....jpg file. Procedural Texture. Add variable 0..1 called 'xx'. Put the following code (a snippet from some HSL tinkering) into R, G and B channels. 

var mx=max(R,G,B);var mn=min(R,G,B);var mr=mx-mn;var ms=mx+mn;var ifmo=roundup(mr-.001);var ll1=ifmo*ms/2;var iflo=roundup(.5-ll1);var ss1=ifmo*(iflo*mr/ms+(1-iflo)*mr/(2-ms+.001));var ifrx=1-roundup(mx-R-.001);var ifgx=1-roundup(mx-G-.001);var ifbx=1-roundup(mx-B-.001);var hr=ifrx*(1-ifgx)*(6*roundup(B-G)+(G-B)/mr);var hg=ifgx*(1-ifbx)*(2+(B-R)/mr);var hb=ifbx*(1-ifrx)*(4+(R-G)/mr);var hh1=ifmo*(hr+hg+hb)/6;xx

You should see the value which is in the xx variable (0 to 1, black to white) as the rest are vars. But what I'm getting is the variable acting on the colours within the image, but not the mono. Just to confuse things further, if you remove the last var statement (var hh1=ifmo*(hr+hg+hb)/6;) it works as it should.

Don't know if its significant, but I created the image using shapes and no (white) background and exported it to jpg. I re-did this export and same effect. I then tried it with another exported file and had a similar effect.

Something to do with exporting of files with no background to jpg? Still odd about the PT code effect.

EDIT: Hmm. More tinkering. Don't think it's export. Happening also on fresh pixel image.

RGBCMYKGW solid and gradients.jpg

image.png

Dave Straker

Cameras: Sony A7R2, RX100V

Computers: Win10: Chillblast i9 Custom + Philips 40in 4K & Benq 23in; Surface Pro 4 i5; iPad Pro 11"

Favourite word: Aha. For me and for others.

Link to post
Share on other sites
  • Moderators

Hi Dave, 

Can you attach the .afphoto file for me please? I need some time to get my head aorund this one and your file would make me feel a lot better about it 😅

Actually just reproduced it by copy/pasting. Leave it with me for a bit! 

Link to post
Share on other sites
On 7/24/2020 at 9:33 AM, Chris B said:

Hi Dave,

Your equation is causing a 'divide by zero' error using 'greyscale' RGB values which is why it is not working on those colours.

The equation has been broken down and attached in an Excel spreadsheet (also a screenshot incase you do not have Excel). 

 

 

Thanks, @Chris B. Pardon delay in responding. Also pardon bug in code! I usually add .001 to divisors to avoid div0 errors but got lulled by ifmo variable mono tweak. I do use Excel to develop code, then concatenate and copy to APh TP. Please send my thanks to whoever found this.

Watch out for interesting macros coming out in InAffinity channel. I'm currently having fun exploring possibilities with colour.

Dave Straker

Cameras: Sony A7R2, RX100V

Computers: Win10: Chillblast i9 Custom + Philips 40in 4K & Benq 23in; Surface Pro 4 i5; iPad Pro 11"

Favourite word: Aha. For me and for others.

Link to post
Share on other sites
24 minutes ago, dmstraker said:

I usually add .001 to divisors to avoid div0 errors

So that explains three of the four ‘#DIV/0’ errors, Dave, because you’re dividing by mr instead of (mr+.001). But what about the last one, where the divisor is 6?? :/

Alfred online2long.gif
Affinity Designer/Photo/Publisher for Windows 1.9.2 • Windows 10 Home (4th gen Core i3 CPU)
Affinity Photo for iPad 1.9.2 • Designer for iPad 1.9.2 • iPadOS 14.4.2 (iPad Air 2)

Link to post
Share on other sites
9 minutes ago, Alfred said:

So that explains three of the four ‘#DIV/0’ errors, Dave, because you’re dividing by mr instead of (mr+.001). But what about the last one, where the divisor is 6?? :/

You're right, Alfred. How is that div0? Now I'm also puzzled.

Edit: There's also the puzzle of the original post, where odd effects are seen.

Dave Straker

Cameras: Sony A7R2, RX100V

Computers: Win10: Chillblast i9 Custom + Philips 40in 4K & Benq 23in; Surface Pro 4 i5; iPad Pro 11"

Favourite word: Aha. For me and for others.

Link to post
Share on other sites

... though thinking about it, when hr, hg and hb are results of div0 then using them in any further calculation may also throw a div0 error.

Dave Straker

Cameras: Sony A7R2, RX100V

Computers: Win10: Chillblast i9 Custom + Philips 40in 4K & Benq 23in; Surface Pro 4 i5; iPad Pro 11"

Favourite word: Aha. For me and for others.

Link to post
Share on other sites
5 minutes ago, dmstraker said:

... though thinking about it, when hr, hg and hb are results of div0 then using them in any further calculation may also throw a div0 error.

Ah, yes! Well spotted!! detective.gif

Alfred online2long.gif
Affinity Designer/Photo/Publisher for Windows 1.9.2 • Windows 10 Home (4th gen Core i3 CPU)
Affinity Photo for iPad 1.9.2 • Designer for iPad 1.9.2 • iPadOS 14.4.2 (iPad Air 2)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Please note there is currently a delay in replying to some post. See pinned thread in the Questions forum. These are the Terms of Use you will be asked to agree to if you join the forum. | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.