Borrar filtros
Borrar filtros

Why won't imwrite save to a 16 bit tiff when called from a function?

11 visualizaciones (últimos 30 días)
Harshad Vishwasrao
Harshad Vishwasrao el 1 de Jun. de 2016
Editada: Pavel Dey el 10 de Jun. de 2016
Hello world, If I run imwrite from the command line, it will write an uint16 bit array into a 16 bit tif file - no problem. But the same command executed from within a function will save an 8 bit image. Has anyone seen this before, and does anybody know how to fix it?
Thanks.
  2 comentarios
Geoff Hayes
Geoff Hayes el 2 de Jun. de 2016
Harshad - please share your code that writes the image to file (as called from your function).
Harshad Vishwasrao
Harshad Vishwasrao el 3 de Jun. de 2016
Editada: Geoff Hayes el 3 de Jun. de 2016
Hi Geoff, the imwrite line is:
**************************
outputimage=deconvlucy(inputimage,psf,decon_iter);
for k=1:imageslices
imwrite(outputimage(:,:,k),outfilename,'WriteMode','append');
end;
*************************
'outputimage' is a uint16 stack of images generated by deconvolution with deconvlucy. If I take 'outputimage' and write it to a tif using that for loop from the command line - no problem it gets saved as a 16bit tif. But that same command executed from within the function saves an 8bit tif.
Thanks for your help! -Harsh

Iniciar sesión para comentar.

Respuestas (1)

Pavel Dey
Pavel Dey el 10 de Jun. de 2016
Editada: Pavel Dey el 10 de Jun. de 2016
That should not happen. Running a code from Command Window or from a script are same. Please make sure you are not missing anything else. I ran a sample code at my end, and it worked well.
I am posting the code. I converted the uint8 image into an uint16 image first. Then I performed the similar operation on that. Run this in your system and see if it is still showing the issue.
function imwriteIssueML
close all
I = imread('ngc6543a.jpg');
I=im2uint16(I);
figure,imshow(I)
PSF = fspecial('gaussian',7,10);
V = .0001;
BlurredNoisy = imnoise(imfilter(I,PSF),'gaussian',0,V);
figure,imshow(BlurredNoisy)
WT = zeros(size(I));
WT(5:end-4,5:end-4) = 1;
J1 = deconvlucy(BlurredNoisy,PSF);
figure,imshow(J1)
for k=1:3
imwrite(J1(:,:,k),'MyOutput.tif','tif','WriteMode','append');
end
output=imread('MyOutput.tif');

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by