Pixel Math Channel Index Error messages/Error Index somewhere

gsedun

Member
May 11, 2016
13
0
66
Victoria, B.C., Canada
I am new to Pixel Math. I'm using a set of expressions given online that work for the author but when I try them myself I get a "channel index out of range" error. I tried it in a project and even though I was referencing three linear images it gave an error about a PSF. I then made a new project with just four linear files in it, RGB and Ha and it complained about the Green channel index being out of range. Is there a reference somewhere that would help understand what this channel index error even means?

Thanks

Garry
 

pfile

PTeam Member
Nov 23, 2009
5,099
41
the channel index refers to the channel of the view under consideration... so a mono image has 1 channel and although it's a degenerate case, i think you can use $T[0] or view_name[0] to refer to the single channel of a mono image ($T or view_name alone would work since there's no need to specify when there is only one channel.)

an RGB image has 3 channels, so if you want pixelmath to operate on only one of those channels, you need to specify an index (otherwise, just like with the mono image, it operates on all 3 channels in the image.) $T[0] = R channel, $T[1] = G channel, $T[2] = B channel.

anyway in your case if you applied an expression with [1] and [2] to a mono image, or referenced a mono image with [1] or [2], that's an error because a mono image only has channel 0.

in computer programming 0 is considered the first ordinal integer, which is a little weird because normally we count from 1. but you'd be wasting a counting number if you started with 1 - on old systems (say, 8-bit processors) you could only count to 255 with a single byte and starting with 0 lets you count to 256.

rob
 

gsedun

Member
May 11, 2016
13
0
66
Victoria, B.C., Canada
Further to that:

Here are the expressions:

R/K: $T[0]*(1-HaRed) + Ha*HaRed
G: $T[1]*(1-HaGreen) + Ha*HaGreen
B: $T[2]*(1-HaBlue) + Ha*HaBlue
Symbols: HaRed=0.8, HaGreen=0, HaBlue=0.15

It complained about the Green channel index so, as a stab at solving it, I set the HaGreen value to something greater than 0 - same error. It processed the R/K expression fine.
 

gsedun

Member
May 11, 2016
13
0
66
Victoria, B.C., Canada
Further to that:

Here are the expressions:

R/K: $T[0]*(1-HaRed) + Ha*HaRed
G: $T[1]*(1-HaGreen) + Ha*HaGreen
B: $T[2]*(1-HaBlue) + Ha*HaBlue
Symbols: HaRed=0.8, HaGreen=0, HaBlue=0.15

It complained about the Green channel index so, as a stab at solving it, I set the HaGreen value to something greater than 0 - same error. It processed the R/K expression fine.
Further to that:

Here are the expressions:

R/K: $T[0]*(1-HaRed) + Ha*HaRed
G: $T[1]*(1-HaGreen) + Ha*HaGreen
B: $T[2]*(1-HaBlue) + Ha*HaBlue
Symbols: HaRed=0.8, HaGreen=0, HaBlue=0.15

It complained about the Green channel index so, as a stab at solving it, I set the HaGreen value to something greater than 0 - same error. It processed the R/K expression fine.
Hi Rob - I posted the expressions exactly at the same time you responded. Can you see a problem with the expressions?

Thanks,

Garry
 

pfile

PTeam Member
Nov 23, 2009
5,099
41
well again, as i explained, it depends on what image you are applying this to. $T refers to the currently selected view (the window with a blue titlebar) when pressing the square button on PixelMath, or it refers to whatever image you dragged PixelMath's triangle to.

all i can say is you must have applied this expression to a mono image.

it looks you are trying to blend an Ha image into an RGB wideband image?

rob

edit: changing HaGreen won't do anything as far as channel indicies are concerned. setting HaGreen to 0 means you want the Ha image to contribute 0% to the green channel of what you are applying to.
 

gsedun

Member
May 11, 2016
13
0
66
Victoria, B.C., Canada
Don't I have to give the green and blue channels a different index number to get an RBG Image out of this? Yes, I am trying to combine an Has with a RGB. All are linear files.

Thanks again,

Garry
 

pfile

PTeam Member
Nov 23, 2009
5,099
41
$T refers to the target image that PM is being applied to. each channel of the target image is being read in, added to the Ha image (which only has 1 channel), in different amounts, based on the weights in the symbols area, and then written back out to the target image. the target image will be overwritten with the blend. the indicies in the expression make sure that the green channel expression only reads from the green channel, the red channel expression only reads from the red channel, etc.

what is the target image? it needs to be an existing RGB image. if you have 3 mono channels (R, G, B) sitting around as 3 views, then the expression you are using is not going to work. you need to explicitly reference those 3 images (one each in the R, G, B lines of pixelmath) and then tell pixelmath to make a new image with 3 channels.

rob