Login  Register

Re: Croping images with border equal to zero

Posted by Krs5 on Jun 11, 2015; 3:47pm
URL: http://imagej.273.s1.nabble.com/TrakEM2-segmentation-with-polygon-ROI-not-working-Bug-tp5013118p5013127.html

I am not totally sure what you want to select but this code will crop an area including the white border.

run("Blobs (25K)");
//run("Canvas Size...", "width=276 height=274 position=Center zero");
//run("Threshold...");
makeRectangle(54, 46, 118, 122);
run("Make Band...", "band=5");
setForegroundColor(255, 255, 255);
run("Fill", "slice");
setThreshold(0, 0);
setOption("BlackBackground", false);
run("Analyze Particles...", "add");
roiManager("Select", 0);
run("Crop");

Best wishes

Kees

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Gabriel Landini
Sent: 11 June 2015 16:33
To: [hidden email]
Subject: Re: Croping images with border equal to zero

On Thursday 11 Jun 2015 17:06:50 CARL Philippe wrote:
> I have some issues with selecting and cropping a part of my images.
> The pictures I have look like the following ones:
> run("Blobs (25K)");
> run("Canvas Size...", "width=276 height=274 position=Center zero");

Hi,
There is an auto crop plugin in Fiji.
Alternatively you could write a macro that just scans the image borders by rows and columns, going towards the centre and stops when a row or column has non-zero pixels. Then use those coordinates to define a rectangular region and then use the Crop command.

Cheers

Gabriel

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

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