Filter löschen
Filter löschen

write (save) an image file

2 Ansichten (letzte 30 Tage)
Elysi Cochin
Elysi Cochin am 31 Jan. 2014
Kommentiert: Syed Mobashir am 12 Mär. 2015
i had a .mha file, i used the below two lines to display the image and i get the first full image as in the link below....
V = mha_read_volume('BRATS_HG0001_truth.mha');
imshow(squeeze(V(:,:,round(end/2))),[]);
please can someone help me how to save that image to a jpg or bmp or tiff file....
i tried
imwrite(squeeze(V(:,:,round(end/2))),'filename.bmp')
but i'm not getting the image... i get the outline of the image as shown in link (image(b))... what should i do to save as image(a)

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 31 Jan. 2014
Notice that when you call imshow you are providing the [] second parameter. That tells imshow() to effectively shift and scale the data so that it runs between 0 and 1. You can do the same tranformation:
newimage = squeeze(V(:,:,round(end/2)));
minimage = min(newimage(:));
maximage = max(newimage(:));
scaledimage = (newimage - minimage) ./ (maximage - minimage);
imwrite(scaledimage, 'filename.bmp');
  4 Kommentare
Elysi Cochin
Elysi Cochin am 31 Jan. 2014
now it worked... thank you Walter Roberson and Image Analyst for your help....
Syed Mobashir
Syed Mobashir am 12 Mär. 2015
i am also getting the same black image. can you tell me this code? plzzz i need this urgent

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by