Page 1 of 1
RGB not available
Posted: 2017-03-04T03:33:51-07:00
by ImageLost
Hi All, I am attempting to open a file and swap pixels with certain colors for other colors, problem is, ImageMagick, cannot open the RGB values correctly!, I have tried about 5 ways, and either get a floating point, or a 16 bit number, and, even when I divide the number by 255/256 the number is something like 15% or more error (fuzz)!.
I was wondering if Imagemagic is going to release a call function that accurately returns the proper RGB value?
Re: RGB not available
Posted: 2017-03-04T07:56:18-07:00
by snibgo
I don't use Perl, but see
http://www.imagemagick.org/script/perl-magick.php
How about GetPixel? I suppose "normalized=true" means the result is typically in the range 0.0 to 1.0, otherwise it will be zero to QuantumRange. Or GetPixels?
If you want many values, GetVirtualPixels may be the best choice.
What other ways have you tried? Showing your image (you can upload to somewhere like dropbox.com and paste hte URL here) and your code will help us to help you.
Re: RGB not available
Posted: 2017-03-04T08:28:23-07:00
by ImageLost
Ok, so what I did in the end was use the large numbers (upto 65535) in my if statements to filter the color i wanted, THEN attempted to change the color!. That was the next problem!, I was getting a black, or white replacement of the color, with some expert fiddling, I found that the issue was with the colors array in "setPixel(width => 1, height => 1,x => $u, y => $n,color=>[@Colors]);"
The problem being, and i have noticed not only have others had the problem, and been forced to resolve it with up/down grading, is that the different values in @Colors have to be between 0 and 1(floating points). This, was a result I was getting for colors in attempting to fix my original problem!. It is a serious issue and request that imagemagic acknowledge this threat and fix the bug!
Re: RGB not available
Posted: 2017-03-04T08:38:44-07:00
by snibgo
Under SetPixel, it says "By default normalized pixel values are expected." Where is the bug?
Re: RGB not available
Posted: 2017-03-04T20:03:35-07:00
by ImageLost
I have never seen colors as floating points, and, it is actually very difficult for the average programmer to pick up on that, in fact I will go so far as to say, not being able to work that out, would drive them to another graphic platform!. I do remember reading somewhere that colors were normally floating points (maybe to imagemagick), somewhere in some small print!. SO it is not a bug, just poor planing by the team!?
Re: RGB not available
Posted: 2017-03-04T20:07:33-07:00
by fmw42
Internally, IM scales pixel values from the quantumrange of the 16-bit per channel images (range 0 to 65535 integers) or 8-bit per channel images (range 0 to 255 integers) to the range 0 to 1 (floats). But when processing is done, it converts back to integers of the quantumrange before writing out the image.
Re: RGB not available
Posted: 2017-03-04T20:12:32-07:00
by snibgo
Under SetPixel it says, "color=>array of float values". If the average programmer doesn't realise that means floating point, there is no hope.
GetPixel has an option "normalize=>{true, false}". Perhaps SetPixel also has this as an undocumented option.