Help regarding bin and tif file usage

I have a code that works fine with bin file that is .bin file but I have to use it with an .tif file. Can anyone help me with this
N=2408;M=3199;
lambda=500*10^(-9);
h=0.050;
z=0.1;
z0_start=0.001;
z0_end=0.003;
z0_step=0.0002;
fid=fopen('myBin.bin','r');
hologramO=fread(fid,[N M],'double');
fclose(fid);
S=round((z0_end-z0_start)/z0_step);
reconstructionO=zeros(N,M,S);
for ii=1:S
z0=z0_start+ii*z0_step;
area=z0*h/z;
prop=PropagatorS(N,M,lambda, area, z0);
recO=abs(IFT2Dc(FT2Dc(hologramO).*prop));
reconstructionO(:,:,ii)=recO(:,:);
imshow(rot90(abs(reconstructionO(:,:,ii))),[]);
colormap(gray)
pause(0.01);
fid=fopen(strcat('b_reconstruction_z0_',int2str(z0*100000),'_area_',int2str(area*100000),'um.bin'),'w');
fwrite(fid,recO,'real*4');
fclose(fid);
p=recO;
p=255*(p-min(min(p)))/(max(max(p))-min(min(p)));
imwrite(rot90(p),gray,strcat('b_reconstruction_z0_',int2str(z0*100000),'_area_',int2str(area*100000),'um.jpg'));
end
In line 8 instead of reading data from a .bin file I have to read it from a .tif file. How should I change the code.

4 comentarios

Rik
Rik el 18 de Ag. de 2020
imread will probably already be enough. You are currently reading in a file with one format, and you want to switch to reading a file with another. You need to make sure the variable that comes out is the format you expect. imread will probably already return the values you need, although it is possible you need to rescale the data.
Without a better description of your data definition it is hard to tell. This is something you need to figure out on your own.
Walter Roberson
Walter Roberson el 24 de Nov. de 2020
(I cannot reply to your recent email because your university blocks my email provider.
... if you had posted your question to MATLAB Answers then I could have responded...)
RAJESHWAR R
RAJESHWAR R el 24 de Nov. de 2020
ok I will post it here
RAJESHWAR R
RAJESHWAR R el 24 de Nov. de 2020
I have posted it just now in matlab answers.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Variables en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 18 de Ag. de 2020

Comentada:

el 24 de Nov. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by