Login  Register

Re: RGB profiler

Posted by Michael Schmid on May 02, 2011; 8:02am
URL: http://imagej.273.s1.nabble.com/RGB-profiler-tp3684784p3684786.html

Hi Damon, Michael,

In imageJ, 16-bit RGB images are a kind of stack, so you could try  
the StackProfilePlot and StackProfileData macros on the ImageJ web site.

Michael
________________________________________________________________

On 30 Apr 2011, at 02:41, Damon Poburko wrote:

> On 4/29/2011 2:13 PM, Cammer, Michael wrote:
>> Is there an RGB or multichannel profiler for 16 bit images?
>> Thanks!
>>
>> ________________________________________________________
>> Michael Cammer, Assistant Research Scientist
>> Skirball Institute of Biomolecular Medicine
>> Lab: (212) 263-3208  Cell: (914) 309-3270
> Hi Michael,
>
>  Based on some previous threads, I worked up the code below. I am  
> pretty sure that there are other macros around that have a very  
> similar function. Feel free to have a whirl with this and see what  
> you think.
>
> (code below)
>
> Damon--
>
> Post Doctoral Fellow
> Tsien Lab, Molecular&  Cellular Physiology
> Stanford University
>
> requires("1.42l");
> print("\\Clear");                     //clear log
> print("Results", "\\Clear");
> run("Clear Results");
>
> //
> ======================================================================
> ==========================================
>
> if (selectionType==-1)
> exit("Area selection required");
> run("Set Measurements...", "area mean min centroid shape  
> redirect=None decimal=3");
> length = selectionLength();
> imageName = getTitle();
> baseName = imageName;
>
> selectWindow(baseName);
> setSlice(1);
> profile1=getProfile();
> Array.getStatistics(profile1, min, max, mean, stdDev);
> max1 = max;
> selectWindow(baseName);
> setSlice(2);
> profile2=getProfile();
> Array.getStatistics(profile2, min, max, mean, stdDev);
> max2 = max;
> profilesMax = maxOf(max1,max2);
> selectWindow(baseName);
> if (nSlices() == 3) {
> selectWindow(baseName);
> setSlice(3);
> profile3=getProfile();
> Array.getStatistics(profile3, min, max, mean, stdDev);
> max3 = max;
> // max = maxOf(max,max3);
> profilesMax = maxOf(max3,profilesMax);
> }
>
> chkSkipBlue = call("ij.Prefs.get", "dialogDefaults.default3", true);
> if ( (chkSkipBlue != true)&&  (chkSkipBlue != false) ) chkSkipBlue  
> = false;
>
> Dialog.create("Align Images");
> Dialog.addCheckbox("run background subtraction?:", false);
> Dialog.addNumber("rolling ball size (pixels)", 20);
> Dialog.addNumber("scale green vs red", 1.0);
> Dialog.addNumber("set Y Max (0 = autoscale)", 0);
> Dialog.addCheckbox("common autoscale?:", false);
> Dialog.addCheckbox("skip blue channel ?:", chkSkipBlue);
> Dialog.addNumber("plot scale (plot width/line length))", 1);
>
> Dialog.show();
>   //------------------------------------------------------------------
> ----------------------
> runBkgdSubtr = Dialog.getCheckbox();
> ballSize = Dialog.getNumber();
> scaleFactor = Dialog.getNumber();
> yMax = Dialog.getNumber();
> commonYMax = Dialog.getCheckbox();
> skipBlue = Dialog.getCheckbox();
> call("ij.Prefs.set", "dialogDefaults.default3", skipBlue);
> plotScale = Dialog.getNumber();
> plotWidth = round(length / plotScale);
>
> setBatchMode(true);
>
> if (runBkgdSubtr == true) run("Subtract Background...",  
> "rolling="+ballSize+"");
> if (commonYMax == true) yMax = profilesMax;
>
> if (yMax == 0 ) {
> setMax = "";
> } else {
> setMax = "maximum="+ yMax + " fixed ";
> }
> run("Profile Plot Options...", "width="+plotWidth+" height=200  
> minimum=0 " + setMax + "draw");
> selectWindow(baseName);
> setSlice(1);
> run("Plot Profile");
> run("Invert");
> rename("red");
> selectWindow(baseName);
> setSlice(2);
> run("Plot Profile");
> run("Invert");
> rename("green");
> selectWindow(baseName);
> if ( (nSlices() == 3)&&  skipBlue == false) {
> selectWindow(baseName);
> setSlice(3);
> run("Plot Profile");
> run("Invert");
> rename("blue");
> mergeBlue = "blue";
> } else {
> mergeBlue = "*None*";
> }
>
> run("Merge Channels...", "red=red green=green blue="+mergeBlue+"  
> gray=*None* create");
>
>
> setBatchMode("exit and display");
>
> //
> ======================================================================
> ==========
> //
> ======================================================================
> ==========
>
> function selectionLength() {
>
>      getSelectionCoordinates(x, y);
>      segments = newArray(x.length-1);
>      lineLength =0;
>      for (i=1; i<x.length; i++) {
>       segments[i-1] =  sqrt( pow( (x[i-1] - x[i]),2) + pow( (y[i-1]  
> - y[i]),2) );
> lineLength = lineLength + segments[i-1];
>      }
> return lineLength;
> }
>
> //
> ======================================================================
> ==========
> //
> ======================================================================
> ==========