imp.setRoi(roi) # Now, iterate each peak, defining a small interval centered at each peak, # and measure the sum of total pixel intensity, # and display the results in an ImageJ ResultTable. table = ResultsTable() for peak in peaks: # Read peak coordinates into an array of integers peak.localize(p) # Define limits of the interval around the peak: # (sigmaSmaller is half the radius of the embryo) minC = [p[i] - sigmaSmaller for i in range(img.numDimensions())] maxC = [p[i] + sigmaSmaller for i in range(img.numDimensions())] # View the interval around the peak, as a flat iterable (like an array) fov = Views.flatIterable(Views.interval(img, minC, maxC)) # Compute sum of pixel intensity values of the interval # (The t is the Type that mediates access to the pixels, via its get* methods) s = sum(t.getInteger() for t in fov) # Add to results table table.incrementCounter() table.addValue("x", p[0]) table.addValue("y", p[1]) table.addValue("sum", s) table.show("Embryo intensities at peaks") from operator import add import csv # The minumum and maximum coordinates, for each image dimension,
imp.setRoi(roi) # Now, iterate each peak, defining a small interval centered at each peak, # and measure the sum of total pixel intensity, # and display the results in an ImageJ ResultTable. table = ResultsTable() for peak in peaks: # Read peak coordinates into an array of integers peak.localize(p) # Define limits of the interval around the peak: # (sigmaSmaller is half the radius of the embryo) minC = [int(p[i] - sigmaSmaller) for i in xrange(img.numDimensions())] maxC = [int(p[i] + sigmaSmaller) for i in xrange(img.numDimensions())] # View the interval around the peak, as a flat iterable (like an array) square = Views.flatIterable(Views.zeroMin(Views.interval(img, minC, maxC))) s1 = sum(t.getInteger() for t in square) area1 = Intervals.numElements(square) # Use a sphere instead radius = sqrt(area1 / pi) # same area for both print sigmaSmaller, radius circle = Masks.toIterableRegion(GeomMasks.closedSphere(p, radius)) s2 = sum(t.getInteger() for t in Regions.sample(circle, imgE)) area2 = Intervals.numElements(circle) print area1, area2 # Compute sum of pixel intensity values of the interval # (The t is the Type that mediates access to the pixels, via its get* methods) # Add to results table