def saveHuePlot(slices, bins, floor, ceiling): startTime = time.time() histogram = DataParse.loadStack(slices, bins, floor, ceiling, bits=12,segmented=False, colorSpace="HSV") filename = "HSV Plot" + str(bins) + "Bins" + "Floor" + str(floor) + "Ceiling" + str(ceiling) + ".png" ColorPlots.huePlot(histogram, bins, filename) endTime = time.time() print "Total Time: %g Seconds" % (endTime-startTime) print "For %g Bins" % bins
def LABVisualization(bins, slices, project=True,color=False,fullOpacity=True, data = "8bit"): startTime = time.time() colorMax = 255 if data == "8bitsegmented": histogram = DataParse.loadStack(300, 200, 3000, mode="8bit", segmented=True) elif data == "8bit": histogram = DataParse.loadStack(300, 200, 3000, mode="8bit", segmented=False) elif data == "12bit": histogram = DataParse.loadStack(300, 200, 3000, mode="12bit", segmented=False) colorMax = 4095 ColorPlots.histogramToLAB(histogram, colorMax, slices, project=project, color=color, fullOpacity=True) endTime = time.time() print "Total Time: %g Seconds" % (endTime-startTime)
def histogramCompressedFill(pix, targetBins, floor, ceiling, colorMax, mode="RGB"): blankPlot = ColorPlots.blankPlot(targetBins) inputRange = float(ceiling - floor) alpha = targetBins/inputRange for i in range(1300): for j in range(1300): [R, G, B] = [pix[i,j][0], pix[i,j][1], pix[i,j][2]] if mode == "LAB": [L,A,B] = Utils.RGBToLAB([R, G, B], colorMax) if L < floor or L > ceiling: continue x = int(((A+128)/256.) * targetBins) y = int(((B+128)/256.) * targetBins) blankPlot[x][y] += 1 elif mode == "HSV": [hue, sat, val] = Utils.RGBToHSV([R, G, B], colorMax) if val < floor or val > ceiling: continue y = int(((val - floor) / inputRange) * targetBins) coneWidthAtY = int(targetBins * (val/100.)) xMin = (targetBins/2.) - (coneWidthAtY/2) x = int(((hue/360.)*coneWidthAtY) + xMin) polarData = [[(val/100.)*(targetBins/2.3), (hue/360.)*2*math.pi, 0]] coords = Utils.polarToBins(polarData, targetBins) x = coords[0][0] y = coords[0][1] blankPlot[x][y] = Utils.HSVToRGB(hue*2*math.pi/360., sat, val) elif mode == "RGB": if math.sqrt(R**2 + G**2 + B**2) < floor: continue if math.sqrt(R**2 + G**2 + B**2) > ceiling: continue x = int(((R - floor) / inputBins) * targetBins) y = int(((G - floor) / inputBins) * targetBins) z = int(((B - floor) / inputBins) * targetBins) blankHistogram[x][y][z] += 1 histogram = blankPlot return histogram