Page 1 of 3

Picking a single RED value, and all the G and B (0-255)

Posted: 2015-10-15T11:11:29-07:00
by gaylorr
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!

Re: Picking a single RED value, and all the G and B (0-255)

Posted: 2015-10-15T11:13:23-07:00
by gaylorr
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!

Re: Picking a single RED value, and all the G and B (0-255)

Posted: 2015-10-15T11:29:32-07:00
by snibgo
I don't understand what you want.
gaylorr wrote:... be dumped into a new image with no other background pixels (not alpha, just no other colors and not black or white.)
"no other background pixels"? An image has pixels. Pixels have colours. They may be opaque, or have an alpha value.

Re: Picking a single RED value, and all the G and B (0-255)

Posted: 2015-10-15T11:34:39-07:00
by gaylorr
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.

Re: Picking a single RED value, and all the G and B (0-255)

Posted: 2015-10-15T11:39:46-07:00
by snibgo
Sorry, I've never heard of interlaced .png, and don't know how to make one.

Re: Picking a single RED value, and all the G and B (0-255)

Posted: 2015-10-15T11:47:22-07:00
by gaylorr
just as an FYI...so it gets explained better than I can:

https://en.wikipedia.org/wiki/Portable_Network_Graphics

Re: Picking a single RED value, and all the G and B (0-255)

Posted: 2015-10-15T11:57:26-07:00
by fmw42
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.

Re: Picking a single RED value, and all the G and B (0-255)

Posted: 2015-10-15T12:04:26-07:00
by gaylorr
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.

Re: Picking a single RED value, and all the G and B (0-255)

Posted: 2015-10-15T12:09:40-07:00
by fmw42
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.)
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.

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
see http://www.imagemagick.org/Usage/files/#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)

Posted: 2015-10-15T12:13:01-07:00
by gaylorr
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? ;-)

Re: Picking a single RED value, and all the G and B (0-255)

Posted: 2015-10-15T12:16:08-07:00
by gaylorr
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 ?

Re: Picking a single RED value, and all the G and B (0-255)

Posted: 2015-10-15T12:16:54-07:00
by fmw42
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)

Posted: 2015-10-15T12:22:14-07:00
by gaylorr
fmw42 wrote:One way is:

Code: Select all

convert image txt:- | grep "rgb(132" | convert - -background none -channel rgba -fill white +opaque none newimage
I tried this at a windows command prompt and it complained about grep?

Re: Picking a single RED value, and all the G and B (0-255)

Posted: 2015-10-15T12:23:40-07:00
by fmw42
As I said that was a unix command. It does not work on windows.


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)

Posted: 2015-10-15T12:25:21-07:00
by gaylorr
LOL...oh...damn...sorry.