def test(): # print("Test not yet written, ending program") import main, itktest # import processing testfish = "/scratch/images/J29-33/rec_J29-33_33D_PTAwt_16p2_30mm_w4Dd__x218_y232_z1013_orig_10um.nhdr" hparts, npdata = main.unpacker(testfish, hdrstring=False) npdata = npdata.reshape(hparts["dsize"][::-1]) #Canny Testing npcanny = itktest.canny_edge_detector(npdata[85], returnNP=True) #Hough Lines testing #output = hough_lines(npcanny, d2_iscanny=True) #print(output) #Coordinate testing boolean_data=npdata>18783.5193537 print(get_coordinates(boolean_data))
#Make sure we have the right type for ITK if type(volume)==np.ndarray: itk_volume=si.GetImageFromArray(np.float32(volume)) print(type(itk_volume)) #returnNP=True else: itk_volume=volume #Do the edge detection canny_edges_volume=si.CannyEdgeDetection(itk_volume, **kwargs) if returnNP: return np.asanyarray(si.GetArrayFromImage(canny_edges_volume),dtype="bool8") return canny_edges_volume #def Buffer<TImage>::GetArrayFromImage(TImage*) [with TImage = itk::Image<float, 2u>] if __name__=='__main__': import main #import processing testfish="/scratch/images/J29-33/rec_J29-33_33D_PTAwt_16p2_30mm_w4Dd__x218_y232_z1013_orig_10um.nhdr" hparts,npdata=main.unpacker(testfish,hdrstring=False) npdata=npdata.reshape(hparts["dsize"][::-1]) canny_edge_detector(npdata, returnNP=True) canny_
#%load_ext cythonmagic import gc gc.enable() from scipy import ndimage ''' This is an experiment in the processing of the fish using some of the tools in scipy.ndimage. For the experimental purpose, see trevor's lab notebook page 17. ''' #Stage 1. Load Files #filename="/scratch/joinedImages/resized/rec_J29-33_33D_PTAwt_16p2_30mm_w4Dd_x292_y292_z1047_cubic-0-5_10.0um.nrrd" #filename="/scratch/joinedImages/uint16/rec_J29-33_33D_PTAwt_16p2_30mm_w4Dd_uint16_x586_y586_z2095_5.0um.nrrd" filename="/scratch/joinedImages/uint16/rec_J29-33_33D_PTAwt_16p2_30mm_w4Dd_uint16_x293_y293_z1047_10.0um.nrrd" header,npdata=main.unpacker(filename) npdata=npdata.reshape(header["dsize"][::-1]) #Automatic thresholding of the file thresh=processing.autothreshold(npdata) print(npdata.shape) mask=npdata>thresh #threshed=np.where(mask, npdata, npdata.min) #Do some binary morphology to get rid of excess stuff result=processing.binaryClosing(mask,structure=None, iterations=15) result2=processing.binaryOpening(result,kernel=None, iterations=1)