<http://imagej.1557.x6.nabble.com/file/t382412/1.jpg>
Hi, I want to find the area fraction of blue, red, gold and gray color in the attached image. I am choosing HSB color space in Color Threshold method to identify them. I am using the values of Hue as 0-24 for Red, 24-44 for Gold and 44-150 for Blue colors. But I don't understand how to find the area of gray color in this image. Moreover, the gray color gets included in Hue 24-44, i.e., gold color. -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Without trying but maybe the colorsegmentation plugin can do the job
(http://bigwww.epfl.ch/sage/soft/colorsegmentation/)? Best wishes Kees Dr Ir K.R. Straatman Senior Experimental Officer Advanced Imaging Facility Centre for Core Biotechnology Services University of Leicester www.le.ac.uk/advanced-imaging-facility -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by shubham1278
Part of the problem is that grey isn't a colour, therefore it cannot be selected by Hue.
Grey is an equivalence of the Red, Green and Blue components - you need to decide how equivalent. Which parts of an image appear grey also depends on the camera settings and the illumination - has the white balance been set. Your definition of grey is critical - maybe that the three RGB intensities are within 10% of each other. Starting with the Red image you can calculate the difference of the Blue and Green images from the sum of Red and the second colour (Red - Green)/(Red + Green) and (Red - blue)/(Red + Blue) Then threshold, maybe -0.1 to 0.1, these two images, producing two binary images. Finally combine the two binary images with AND to find the pixels that meet the criteria for the 3 colour Grey pixels. The definition of grey as an equivalence of the RGB intensities will include matching low values - blackish Excluding them should be quite easy. run("Duplicate...", " "); title=getTitle(); run("Add...", "value=1");// ensure all values >zero run("Split Channels"); Red=title+" (red)"; selectImage(Red); rename("Red"); Green=title+" (green)"; selectImage(Green); rename("Green"); Blue=title+" (blue)"; selectImage(Blue); rename("Blue"); run("Image Expression Parser (Macro)", "expression=(A-B)/(A+B) a=Red b=Green c=None"); rename("RedGreen"); run("Image Expression Parser (Macro)", "expression=(A-B)/(A+B) a=Red b=Blue c=None d=None"); rename("RedBlue"); // threshold Tval=0.08;// threshold selectImage("RedGreen"); setThreshold(-Tval, Tval); run("Make Binary"); rename("RedGreenBin"); selectImage("RedBlue"); setThreshold(-Tval, Tval); run("Make Binary"); rename("RedBlueBin"); imageCalculator("AND create", "RedGreenBin","RedBlueBin"); Jeremy Adler BioVis Uppsala -----Original Message----- From: ImageJ Interest Group <[hidden email]> On Behalf Of shubham1278 Sent: den 6 augusti 2019 00:07 To: [hidden email] Subject: Area fraction in colored image <http://imagej.1557.x6.nabble.com/file/t382412/1.jpg> Hi, I want to find the area fraction of blue, red, gold and gray color in the attached image. I am choosing HSB color space in Color Threshold method to identify them. I am using the values of Hue as 0-24 for Red, 24-44 for Gold and 44-150 for Blue colors. But I don't understand how to find the area of gray color in this image. Moreover, the gray color gets included in Hue 24-44, i.e., gold color. -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html När du har kontakt med oss på Uppsala universitet med e-post så innebär det att vi behandlar dina personuppgifter. För att läsa mer om hur vi gör det kan du läsa här: http://www.uu.se/om-uu/dataskydd-personuppgifter/ E-mailing Uppsala University means that we will process your personal data. For more information on how this is performed, please read here: http://www.uu.se/en/about-uu/data-protection-policy -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Perhaps this will help. It's crude, and needs to be adapted to your particular needs, but perhaps it's a useful starting point.
// File: ListColors.java // Author: K R Sloan // Last Modified: 7 August 2019 // Purpose: list colors in an image import ij.*; import ij.plugin.*; import ij.process.*; import java.awt.*; import java.util.*; public class ListColors implements PlugIn { public void run(String arg) { ImagePlus ipl = IJ.getImage(); ImageProcessor ip = ipl.getProcessor(); ColorProcessor cp = (ColorProcessor)ip.convertToRGB(); listColors(cp); } private class ColorNumber implements Comparable<ColorNumber> { private Color color; private long count; public Color getColor(){return this.color;} public long getCount(){return this.count;} public ColorNumber(Color color, int count) { this.color = color; this.count = count; } public void increment() { this.count++; } public int compareTo(ColorNumber other) { if(this.count < other.count) return -1; if(this.count > other.count) return 1; else return 0; } public String toString() { String result = "[" + this.color + ", " + this.count + "]"; return result; } } public void listColors(ColorProcessor cp) { ArrayList<ColorNumber> cNAL = new ArrayList<ColorNumber>(); int width = cp.getWidth(); int height = cp.getHeight(); for(int yPix=0;yPix<height;yPix++) for(int xPix=0;xPix<width;xPix++) { Color color = cp.getColor(xPix,yPix); tally(cNAL, color); } Collections.sort(cNAL); for(int i=cNAL.size()-1;i>=0;i--) { IJ.log("ListColors: " + cNAL.get(i)); } } private void tally(ArrayList<ColorNumber> cNAL, Color color) { for(int i=0;i<cNAL.size();i++) { ColorNumber cn = cNAL.get(i); if(color.equals(cn.getColor())) { // found cn = cNAL.remove(i); cn.increment(); cNAL.add(0,cn); return; } } // not found cNAL.add(0, new ColorNumber(color,1)); } } -- Kenneth Sloan [hidden email] Vision is the art of seeing what is invisible to others. > Hi, > > I want to find the area fraction of blue, red, gold and gray color in the attached image. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |