I'm very new to Imagemagick, but I'm amazed by what it can do.
I'm trying to use it to create a plot of the noise an image of a gradient using data from the command:
C:\temp>convert gimp16bit.tif -crop 1x0+960+0 miff:- | convert - txt:test.txt
The point of the exercise is to identify when an image has been dithered down to a lower bit depth, even when it is carried in a higher bit depth file format. Some programs do not allow you to turn off dither, but it is hard to know if it is present, especially if you do not have equipment that allows you to visually discriminate it.
I would like to be able to plot at least 1k points in order to see the differences between 8bit and 10bit images without resorting to Excel.
Any advice is greatly appreciated.
Don
Plotting noise
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Plotting noise
From your cropped image, get the min and max value, to use for the height of the graph. See http://www.imagemagick.org/script/escape.php (convert image -format "%[min]" info:).
Create a solid color (say white) background image that is as wide as your cropped image and as high as the difference between your min and max values.
Take the txt: output for the cropped data and extract the graylevel for each x value and use that graylevel as the y coordinate. So now you have a list of x,y pairs. Now loop over each pair and subtract the min graylevel from the y values, so you have x,y pairs where y is (graylevel -min_graylevel).
All of the above processing can be done by piping the result of txt: to sed.
Now use -draw to plot a polyline (in black) on your white background image. see
http://www.imagemagick.org/Usage/draw/
I have assumed that your image is grayscale. But if color, then you need to do it separately for each of the R,G,B channels.
You can also generate a plot from the x,y processed pairs using GNUPLOT. Or you can try my bash shell scripts, profile (which does the above) or plot (which uses GNUPLOT), at the link below. Note that I have not tested those scripts on 10bit images, which may have to be processed in IM as 16bits. Most of my tests were likely done with 8-bit images, though I think they should work with 16-bit data.
P.S.
If you are really looking for the noise, then you probably need to subtract a perfect gradient from your image, so that it shows only the difference values. Since the difference may be negative, you may have to recompile IM in HDRI mode to preserve negative values and fractional graylevels. I am not sure my script can handle negative values. So you may need to do what I suggest above.
Create a solid color (say white) background image that is as wide as your cropped image and as high as the difference between your min and max values.
Take the txt: output for the cropped data and extract the graylevel for each x value and use that graylevel as the y coordinate. So now you have a list of x,y pairs. Now loop over each pair and subtract the min graylevel from the y values, so you have x,y pairs where y is (graylevel -min_graylevel).
All of the above processing can be done by piping the result of txt: to sed.
Now use -draw to plot a polyline (in black) on your white background image. see
http://www.imagemagick.org/Usage/draw/
I have assumed that your image is grayscale. But if color, then you need to do it separately for each of the R,G,B channels.
You can also generate a plot from the x,y processed pairs using GNUPLOT. Or you can try my bash shell scripts, profile (which does the above) or plot (which uses GNUPLOT), at the link below. Note that I have not tested those scripts on 10bit images, which may have to be processed in IM as 16bits. Most of my tests were likely done with 8-bit images, though I think they should work with 16-bit data.
P.S.
If you are really looking for the noise, then you probably need to subtract a perfect gradient from your image, so that it shows only the difference values. Since the difference may be negative, you may have to recompile IM in HDRI mode to preserve negative values and fractional graylevels. I am not sure my script can handle negative values. So you may need to do what I suggest above.