Hough transfrom with itk - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Hough transfrom with itk (/thread-11750.html) |
Hough transfrom with itk - Hakookaine - Jul-24-2018 Hello everybody, I need your help ! I've been searching for 2 days how can I use the tranform of Hough (circles on 2D image). For this i need to use itk because my image is in the format .mha. I have already tried something like : HoughFilter = itk.HoughTransform2DCirclesImageFilter.New() HoughFilter.SetInput(MyLastImage) HoughFilter.SetNumberOfCircles(2) HoughFilter.Update() Im1 = HoughFilter.GetOutput() Im1.show()But nothing works, I am searching on the internet but i don't find anything... May someone have an idea for this problem ? Hakoo' RE: Hough transfrom with itk - gontajones - Jul-24-2018 Could you please post your complete code and a link for your MyLastImage ?Maybe this simple example can help you: plot_circular_elliptical_hough_transform RE: Hough transfrom with itk - Hakookaine - Jul-25-2018 This is all the previous code : import numpy from PIL import Image import itk from sys import argv #First, read the image with itk Reader = itk.ImageFileReader.New(FileName="C:/Users/Utilisateur/Desktop/DataPourQuentin/Aimer Omar_SSFP.mha") #Get the image as an itkImage object Reader.Update() MyImage = Reader.GetOutput() #Transform the itkImage into a simple Numpy array MyImageNumpy = itk.GetArrayFromImage(MyImage) #Now look at the first slice of the image MyImagePIL = Image.fromarray(MyImageNumpy[0,:,:]) MyImagePIL.show() #Create the ImageMIP m = len(MyImageNumpy[0,0,:]) n = len(MyImageNumpy[0,:,0]) MyImageMIP = numpy.zeros((n,m)) for i in range (n): for j in range (m): MyImageMIP[i,j] = max(MyImageNumpy[:,i,j]) MyLastImage = Image.fromarray(MyImageMIP)The aim is to take a 3D image and to put it into a 2D image, and then to make a 2D circular transform of hough And this is the following code : PixelType = itk.UC AccumulatorPixelType = itk.F Dimension = 2 ImageType = itk.Image[PixelType,Dimension] AccumulatorImageType = itk.Image[AccumulatorPixelType,Dimension] reader2 = itk.ImageFileReader(ImageType) reader2 = readerType.New() reader2.SetFileName( argv[1] ) reader2.Update() reader2.GetOutput() HoughFilter = itk.HoughTransform2DCirclesImageFilter.New() HoughFilter.SetInput(MyLastImage) HoughFilter.SetNumberOfCircles(2) HoughFilter.SetMinimumRadius(4) HoughFilter.SetMaximumRadius(5) HoughFilter.Update() Im1 = HoughFilter.GetOutput()But after my accumulator image, there is an error |