Hey everybody!
I'm doing a track of a school of fish swimming in a net pen. I need to process 1 fps still frames produced by a multibeam sonar and have gotten quite far in the task, which with my very limited programming skills is beginning to feel like a bit of an ordeal. The aim is to track the area variations of the school with convex hulls. At the moment I have been able to succesfully import my images (~250-400/experiment) as a stack, and wrote a macro to convert them to thresholded binary and apply convex hull by first making point selections by "Find Maxima". Everything is working as planned, except that some of the slices are blank due to fish migrating vertically to a blind spot. My macro makes the convex hull vectors fine, but the whole process ends when there'a blank slice (See attached image), so is there a way to tell ImageJ to skip slices with nothing but 255 value pixels? Thanks! Here's what I've come up with so far. run ("8-bit") for (i = 1;i<=nSlices();i++){ run("Enhance Contrast...", "saturated=0.8 equalize"); run("Despeckle", "slice"); run("Gaussian Blur...", "sigma=0.50 slice"); makePolygon(449,565,599,26,557,29,432,534,363,526,242,25,203,28,344,564); setForegroundColor(0, 0, 0); run("Fill", "slice"); setAutoThreshold("Default"); //run("Threshold..."); setOption("BlackBackground", false); run("Convert to Mask", "method=Default background=Default only"); run("Next Slice [>]"); } run("Analyze Particles...", "size=23-999 pixel show=Masks include stack"); setSlice(1); for (j=1;j<=nSlices();j++){ run("Create Selection"); run("Find Maxima...", "noise=10 output=[Point Selection] light"); run("Convex Hull"); run("Add Selection..."); run("Next Slice [>]"); } |
Dear TimoT,
You could check with getRawStatistics(nPixels, mean, min, max, std, histogram); if the max == 255 and if not skip that image. Kees ________________________________________ From: ImageJ Interest Group [[hidden email]] on behalf of TimoT [[hidden email]] Sent: 20 May 2016 12:58 To: [hidden email] Subject: Macro command to skipping blank slices in a stack Hey everybody! I'm doing a track of a school of fish swimming in a net pen. I need to process 1 fps still frames produced by a multibeam sonar and have gotten quite far in the task, which with my very limited programming skills is beginning to feel like a bit of an ordeal. The aim is to track the area variations of the school with convex hulls. At the moment I have been able to succesfully import my images (~250-400/experiment) as a stack, and wrote a macro to convert them to thresholded binary and apply convex hull by first making point selections by "Find Maxima". Everything is working as planned, except that some of the slices are blank due to fish migrating vertically to a blind spot. My macro makes the convex hull vectors fine, but the whole process ends when there'a blank slice (See attached image), so is there a way to tell ImageJ to skip slices with nothing but 255 value pixels? Thanks! <http://imagej.1557.x6.nabble.com/file/n5016477/Fish_convex.png> Here's what I've come up with so far. run ("8-bit") for (i = 1;i<=nSlices();i++){ run("Enhance Contrast...", "saturated=0.8 equalize"); run("Despeckle", "slice"); run("Gaussian Blur...", "sigma=0.50 slice"); makePolygon(449,565,599,26,557,29,432,534,363,526,242,25,203,28,344,564); setForegroundColor(0, 0, 0); run("Fill", "slice"); setAutoThreshold("Default"); //run("Threshold..."); setOption("BlackBackground", false); run("Convert to Mask", "method=Default background=Default only"); run("Next Slice [>]"); } run("Analyze Particles...", "size=23-999 pixel show=Masks include stack"); setSlice(1); for (j=1;j<=nSlices();j++){ run("Create Selection"); run("Find Maxima...", "noise=10 output=[Point Selection] light"); run("Convex Hull"); run("Add Selection..."); run("Next Slice [>]"); } -- View this message in context: http://imagej.1557.x6.nabble.com/Macro-command-to-skipping-blank-slices-in-a-stack-tp5016477.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 |
Free forum by Nabble | Edit this page |