I have an image, and I’m trying to extract a certain channel depending on how red, blue or green the image is.
For example, if my image is predominately red, I want to extract the red channel. I already have the code which will extract the channels for me:
private ImageProcessor getRedChannel(ImageProcessor ip) {
RGBStackSplitterSean splitter=new RGBStackSplitterSean();
splitter.split(new ImagePlus("tempImage",ip));
ImagePlus red=new ImagePlus("tempImage",splitter.red);
return red.getProcessor();
}
How do I go about determining which channel is the strongest?
Thanks!
Edit:
I ended up doing as @mmgp mentioned. Sum up all intensities for each channel and pick the largest using:
private int getSumPixels(ImageProcessor ip){
int sum = 0;
for(int i=0; i<ip.getWidth(); i++){
for(int k=0; k<ip.getHeight(); k++){
sum = sum + ip.getPixel(i, k);
}
}
return sum;
}
Sum all the intensities per channel and pick the one with the largest sum.