Crop Macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Crop Macro

oselm
Hi all,

I have various pictures of petri dishes and I would like to find a way to crop everything that is outside and just keep the area inside the dish as in the example here below:
Original

Processed


Any suggestion?
Reply | Threaded
Open this post in threaded view
|

Re: Crop Macro

Krs5
I used the Threshold Color menu with Color space Lab selected and settings:
L* 128 - 255
a* 108 - 255
b* 140 - 255
 Select
Edit > Selection > Fit Circle
Edit > Clear Outside

//----------- Macro Code-------------
title = getTitle();
run("Duplicate...", " ");
// Color Thresholder 2.0.0-rc-31/1.49v
// Autogenerated macro, single images only!
min=newArray(3);
max=newArray(3);
filter=newArray(3);
a=getTitle();
call("ij.plugin.frame.ColorThresholder.RGBtoLab");
run("RGB Stack");
run("Convert Stack to Images");
selectWindow("Red");
rename("0");
selectWindow("Green");
rename("1");
selectWindow("Blue");
rename("2");
min[0]=128;
max[0]=255;
filter[0]="pass";
min[1]=108;
max[1]=255;
filter[1]="pass";
min[2]=140;
max[2]=255;
filter[2]="pass";
for (i=0;i<3;i++){
  selectWindow(""+i);
  setThreshold(min[i], max[i]);
  run("Convert to Mask");
  if (filter[i]=="stop")  run("Invert");
}
imageCalculator("AND create", "0","1");
imageCalculator("AND create", "Result of 0","2");
for (i=0;i<3;i++){
  selectWindow(""+i);
  close();
}
selectWindow("Result of 0");
close();
selectWindow("Result of Result of 0");
rename(a);
// Colour Thresholding-------------

run("Analyze Particles...", "add");
selectWindow(title);
roiManager("select", 0);
run("Fit Circle");
setBackgroundColor(0, 0, 0);
run("Clear Outside");

//------------End Macro Code---------------------------------

It is close......

Best wishes

Kees


Dr Ir K.R. Straatman
Senior Experimental Officer
Advanced Imaging Facility
Centre for Core Biotechnology Services
University of Leicester
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif



-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of oselm
Sent: 14 July 2015 11:09
To: [hidden email]
Subject: Crop Macro

Hi all,

I have various pictures of petri dishes and I would like to find a way to crop everything that is outside and just keep the area inside the dish as in the example here below:
Original
<http://imagej.1557.x6.nabble.com/file/n5013548/DSC_6450.jpg>
Processed
<http://imagej.1557.x6.nabble.com/file/n5013548/cropgrayling.jpg>

Any suggestion?



--
View this message in context: http://imagej.1557.x6.nabble.com/Crop-Macro-tp5013548.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html