Picking a single RED value, and all the G and B (0-255)
Picking a single RED value, and all the G and B (0-255)
I have a unique case where I have values in a texture for a 3D model that all represent the "angles" of the orientation of the polygons of said 3D model.
Basically:
I want to choose from an image the single value for vertical faces...which is represented by R: 132...and all of the values (0-255) for B and G and have that selection set be dumped into a new image with no other background pixels (not alpha, just no other colors and not black or white.)
I have tried searching the forum and understanding the command possibilities, but can not figure this out.
Is this possible?
ps I will be doing all of this in windows batch, not perl, etc.
Thanks in advance!
Basically:
I want to choose from an image the single value for vertical faces...which is represented by R: 132...and all of the values (0-255) for B and G and have that selection set be dumped into a new image with no other background pixels (not alpha, just no other colors and not black or white.)
I have tried searching the forum and understanding the command possibilities, but can not figure this out.
Is this possible?
ps I will be doing all of this in windows batch, not perl, etc.
Thanks in advance!
Re: Picking a single RED value, and all the G and B (0-255)
BTW, I would prefer the new image was simply image with all of the values in the requested selection set being filled to "white" with no other background
Thanks!
Thanks!
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Picking a single RED value, and all the G and B (0-255)
I don't understand what you want.
"no other background pixels"? An image has pixels. Pixels have colours. They may be opaque, or have an alpha value.gaylorr wrote:... be dumped into a new image with no other background pixels (not alpha, just no other colors and not black or white.)
snibgo's IM pages: im.snibgo.com
Re: Picking a single RED value, and all the G and B (0-255)
When I open a PNG or PSD in photoshop, it "can" have no alpha, but still have not every pixel in the image have a color value...interlaced...that is what I would prefer the final image be, because I will be running other processes on the resultant image. So I guess I should have just said the result will end up an interlaced .png for further processing...sorry.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Picking a single RED value, and all the G and B (0-255)
Sorry, I've never heard of interlaced .png, and don't know how to make one.
snibgo's IM pages: im.snibgo.com
Re: Picking a single RED value, and all the G and B (0-255)
just as an FYI...so it gets explained better than I can:
https://en.wikipedia.org/wiki/Portable_Network_Graphics
https://en.wikipedia.org/wiki/Portable_Network_Graphics
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Picking a single RED value, and all the G and B (0-255)
see http://www.imagemagick.org/script/comma ... #interlace. Though I do not understand how this makes any difference to other processing. It just stores the pixel data in an r,g,b per row format rather than r,g,b per pixel format or r,g,b per channel format. It does not skip any pixel values. They are all there in any of these formats.
Perhaps you really mean -type pseudocoloralpha i.e. PNG8 with an alpha color rather than -type truecoloralpha i.e. PNG32 with an alpha channel. If that is the case, then write your image with PNG8: or PNG32: prefix.
convert image PNG8:resultimage
convert image PNG32:resultimage
See http://www.imagemagick.org/Usage/formats/#png
I am not sure what this has to do with the original question, though.
Perhaps you really mean -type pseudocoloralpha i.e. PNG8 with an alpha color rather than -type truecoloralpha i.e. PNG32 with an alpha channel. If that is the case, then write your image with PNG8: or PNG32: prefix.
convert image PNG8:resultimage
convert image PNG32:resultimage
See http://www.imagemagick.org/Usage/formats/#png
I am not sure what this has to do with the original question, though.
Re: Picking a single RED value, and all the G and B (0-255)
that could be very true...the resultant output really isn't my issue...but rather how to select exactly what I want from the image. I figured out how to choose a single RGB value, but what I want is a single R value, and ALL of the G and B values and generate some new image from that, filling those result values to white...that's all...
I am sorry if I am over complicating this request, I really am...just a newb to ImageMagick, although I can't figure this out in Photoshop either oddly enough.
I am sorry if I am over complicating this request, I really am...just a newb to ImageMagick, although I can't figure this out in Photoshop either oddly enough.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Picking a single RED value, and all the G and B (0-255)
There is no image format that has only these values and nothing else, unless you write only these pixels to a single row or column of data. But then you lose the context of where each original pixel comes from.I want to choose from an image the single value for vertical faces...which is represented by R: 132...and all of the values (0-255) for B and G and have that selection set be dumped into a new image with no other background pixels (not alpha, just no other colors and not black or white.)
You could write it out to a text file, however, with something like the following in unix.
Code: Select all
convert image txt:- | grep "rgb(132" > data.txt
IM can then read that back into image format, but you will need to tell it what background color you want for all the other pixels, typically transparent.
If you want to do that in one command, then
Code: Select all
convert image txt:- | grep "rgb(132" | convert - -background none newimage
Re: Picking a single RED value, and all the G and B (0-255)
I think the request I made has gotten skewed by the format hangup...I just want to select a range of colors (R=132, G=0-255, and B=0-255) and create an image of white from those values...if the resulting image has alpha or even some other background color (non-white) isn't the part I can't figure out...it's the selection of the above range.
Am I making sense?
Am I making sense?
Re: Picking a single RED value, and all the G and B (0-255)
perhaps if I reduce all of the R values that are not 132 to black, the R=132 to white, and all other non-0 pixel values in the G and B channels to white ?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Picking a single RED value, and all the G and B (0-255)
One way is (unix syntax)
Code: Select all
convert image txt:- | grep "rgb(132" | convert - -background none -channel rgba -fill white +opaque none newimage
Re: Picking a single RED value, and all the G and B (0-255)
I tried this at a windows command prompt and it complained about grep?fmw42 wrote:One way is:
Code: Select all
convert image txt:- | grep "rgb(132" | convert - -background none -channel rgba -fill white +opaque none newimage
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Picking a single RED value, and all the G and B (0-255)
As I said that was a unix command. It does not work on windows.
try
try
Code: Select all
convert image -channel r -separate +channel -fill black +opaque "gray(132)" -fill white -opaque "gray(132)" result
Re: Picking a single RED value, and all the G and B (0-255)
LOL...oh...damn...sorry.