150 likes | 289 Vues
This project presents a comprehensive approach to analyzing astrocyte cells through various image processing techniques using ImageJ. Key topics include algorithms for converting images to 8-bit format, applying thresholding, managing overlapping cell structures with watershed algorithms, and particle analysis. The project includes sample Java code for implementing these algorithms and insights into future work, highlighting the potential for combining all processes into one plugin for improved functionality. This analysis aims to enhance understanding of astrocyte structures and their behaviors.
E N D
PROJECT#3(b)Astrocyte Analysis BY BhimanathiniVenkatsai Sai Kumar Maddula
Contents • Astrocyte Analysis • Algorithm for Converting into 8-bit • Algorithm for Thresholding • Sample code for Thresholding • Overlapping/Touching of cell structure • Watershed Algorithm • Analyze Particles And Future work
Astrocyte Analysis: • Load the stack File into ImageJ File Open Browse Stack File
Converting to 8bit • java.util import Random • imp = IJ.createImage("A Random Image", "8-bit", 512, 512, 1) • Random().nextBytes(imp.getProcessor().getPixels()) • imp.show() Converting to 8bit
1. start set THRESHOLD = 30red = getRedPixelFromImage(row,column) green = getGreenPixelFromImage(row,column) blue = getBluePixelFromImage(row,column) • 2. avg = (red+green+blue)/3 • 3. if(avg<THRESHOLD) paint white else paint black. • 4. end Algorithm for Threshold:
import java.awt.image.BufferedImage; public class ImageOperations { public static BufferedImage Threshold(BufferedImageimg,intrequiredThresholdValue) { int height = img.getHeight(); int width = img.getWidth(); BufferedImagefinalThresholdImage = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB) ; int red = 0; int green = 0; int blue = 0; for (int x = 0; x < width; x++) { // System.out.println("Row: " + x); try { for (int y = 0; y < height; y++) { int color = img.getRGB(x, y); red = ImageOperations.getRed(color); green = ImageOperations.getGreen(color); blue = ImageOperations.getBlue(color); // System.out.println("Threshold : " + requiredThresholdValue); if((red+green+green)/3 < (int) (requiredThresholdValue)) { finalThresholdImage.setRGB(x,y,ImageOperations.mixColor(0, 0,0)); } else { finalThresholdImage.setRGB(x,y,ImageOperations.mixColor(255, 255,255)); } } } catch (Exception e) { e.getMessage(); } } return finalThresholdImage; } private static intmixColor(int red, int green, int blue) { return red<<16|green<<8|blue; } public static intgetRed(int color) { return (color & 0x00ff0000) >> 16; } public static intgetGreen(int color) { return (color & 0x0000ff00) >> 8; } public static intgetBlue(int color) { return (color & 0x000000ff) >> 0; } } Code for Threshold
Overlapping/Touching Cell Structures • Here we have to apply Watershed and Analyze Particles. • So we done with some code for Watershed and to Analyze Particles.
# 1 - Obtain an image blobs = IJ.openImage(“aaa.tip") # Make a copy with the same properties as blobs image: imp = blobs.createImagePlus() ip = blobs.getProcessor().duplicate() imp.setProcessor("blobs copy", ip) # 2 - Apply a threshold: only zeros and ones # Set the desired threshold range: keep from 0 to 74 ip.setThreshold(147, 147, ImageProcessor.NO_LUT_UPDATE) # Call the Thresholder to convert the image to a mask IJ.run(imp, "Convert to Mask", "") # 3 - Apply watershed # Create and run new EDM object, which is an Euclidean Distance Map (EDM) # and run the watershed on the ImageProcessor: EDM().toWatershed(ip) # 4 - Show the watersheded image: imp.show() Watershed algorithm:
# Create a table to store the results table = ResultsTable() # Create a hidden ROI manager, to store a ROI for each blob or cell roim = RoiManager(True) # Create a ParticleAnalyzer, with arguments: # 1. options (could be SHOW_ROI_MASKS, SHOW_OUTLINES, SHOW_MASKS, SHOW_NONE, ADD_TO_MANAGER, and others; combined with bitwise-or) # 2. measurement options # 3. a ResultsTable to store the measurements # 4. The minimum size of a particle to consider for measurement # 5. The maximum size (idem) # 6. The minimum circularity of a particle # 7. The maximum circularity pa = ParticleAnalyzer(ParticleAnalyzer.ADD_TO_MANAGER, Measurements.AREA, table, 0, Double.POSITIVE_INFINITY, 0.0, 1.0) pa.setHideOutputImage(True) if pa.analyze(imp): print "All ok" else: print "There was a problem in analyzing", blobs # The measured areas are listed in the first column of the results table, as a float array: areas = table.getColumn(0) Analyze particles:
Segmentation by 3D Viewer • Combine individual Plugin into one Plugin. Still working on..