Jan-13-2018, 01:55 AM
Hello, I am trying to convert some matlab source code to python and I am having some troubles, could anyone help me?
Here's the matlab version of the code:
Here's the matlab version of the code:
% Author : Umesh Rajashekar, Ian van der Linde %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Define Constants % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% w = 1024; h = 768; % W x H of Images(cropped van Hateren) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Read van Hateren File % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% f1 = fopen(filename,'rb', 'ieee-be'); buf = fread(f1,[w,h],'uint16'); % Read 16bpp image data display_image = buf'; % Note: van Hateren images are flipped display_image = display_image+1; fclose(f1); display_image = display_image/max(display_image(:))*255; figure(1); clf; imagesc(display_image.^0.3);colormap gray;axis image; axis off; hold on;And... heres my version of the converted soure code.
# Author : Umesh Rajashekar, Ian van der Linde arq = open(name, 'rb') arq = np.fromfile(arq, np.uint16, count=-1) #print(arq.shape) #print(name) arq = arq.reshape((self.width, self.height)).T arq = np.transpose(arq) arq = np.add(arq, 1) arq = arq / np.amax(arq) * 255 plt.imshow(arq, cmap='gray'); plt.show()But am I having some troubles, the image isnt the same : (