Dec-18-2018, 12:37 PM
Hi all,
I am trying to converst a series of float32 2D tif images to uint16 images and the read them into a 3D array. I can run the full code to get a float32 array output (float32 in ln1 below, no ln8), but when I try and do the conversion (either before the tif is added to the array as shpwn below, or after the array is created) I get a uint16 array of zeros. I have tried:
and
Help much appreciated!
I am trying to converst a series of float32 2D tif images to uint16 images and the read them into a 3D array. I can run the full code to get a float32 array output (float32 in ln1 below, no ln8), but when I try and do the conversion (either before the tif is added to the array as shpwn below, or after the array is created) I get a uint16 array of zeros. I have tried:
data=numpy.zeros((init.shape[1],init.shape[0],height),dtype=numpy.uint16) del init for j in range(0,height): if selection == 0: image=numpy.swapaxes(numpy.array(Image.open('rec_'+str(j).zfill(5)+'.tif')),0,1) elif selection == 1: image=numpy.swapaxes(numpy.array(Image.open(first.replace('0001',str(j+1).zfill(4)))),0,1) image=ImageMath.eval("(a+b)*(c)", a=image, b=0.001, c=15000000) #arbitrary values here for illustration image = numpy.rint(image)
and
data=numpy.zeros((init.shape[1],init.shape[0],height),dtype=numpy.uint16) del init for j in range(0,height): if selection == 0: image=numpy.swapaxes(numpy.array(Image.open('rec_'+str(j).zfill(5)+'.tif')),0,1) elif selection == 1: image=numpy.swapaxes(numpy.array(Image.open(first.replace('0001',str(j+1).zfill(4)))),0,1) image=skimage.img_as_uint(image) data[:,:,j]=imageand
data=numpy.zeros((init.shape[1],init.shape[0],height),dtype=numpy.uint16) del init for j in range(0,height): if selection == 0: image=numpy.swapaxes(numpy.array(Image.open('rec_'+str(j).zfill(5)+'.tif')),0,1) elif selection == 1: image=numpy.swapaxes(numpy.array(Image.open(first.replace('0001',str(j+1).zfill(4)))),0,1) image = exposure.rescale_intensity(image, in_range='float32', out_range=(0,2)) image=skimage.img_as_uint(image) data[:,:,j]=imagein case it was the scaing from unsigned to signed that was causing the data to be cropped (althouth my data are int positive part of the range). But I still get zeros. I am a coding novice and am not sure why I can;t get the greyscale output I should. I am hopig somwone can explain what I am doing wrong.
Help much appreciated!