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?
RGB not available
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: RGB not available
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.
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.
snibgo's IM pages: im.snibgo.com
Re: RGB not available
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!
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!
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: RGB not available
Under SetPixel, it says "By default normalized pixel values are expected." Where is the bug?
snibgo's IM pages: im.snibgo.com
Re: RGB not available
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!?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: RGB not available
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.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: RGB not available
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.
GetPixel has an option "normalize=>{true, false}". Perhaps SetPixel also has this as an undocumented option.
snibgo's IM pages: im.snibgo.com