Image Processing; converting images

Hi guys. I have images in .im7 format. I've loaded them into Matlab using PivMat and ReadIMX, then formatted them into .mat files ( images ? ). Now, I'm trying to covert them to either .jpg , .tif , .png , .bmp using imwrite but I cannot do so because 'type was struct'. Can I efficiently go from 'structure' format to any of the formats that imwrite recognizes ?

댓글 수: 2

KSSV
KSSV 2017년 7월 6일
You have to extract the required pixel information from the structure and use imwrite.
Damian Wierzbicki
Damian Wierzbicki 2017년 7월 6일
Thank you. If you don't mind me asking: what information would that be ? x ( 1x2048 double ) and y ( 1x2048 double ) and also w ( 2048x2048 double) also the unitx and unity are 'mm' - how'd I deal with that ? These are probably really stupid question, but I just want to make sure if I'm doing it wright.

댓글을 달려면 로그인하십시오.

답변 (2개)

KSSV
KSSV 2017년 7월 6일

0 개 추천

You need to pick the matrix 2048*2048 and use imwrite

댓글 수: 8

Damian Wierzbicki
Damian Wierzbicki 2017년 7월 6일
Thank you again. When I'm trying to do so it spits 'Too many output arguments' out. Do you know why ?
Give the code what you have tried...You should only send the required matrix into imwrite
A = rand(2048);
imwrite(A,'myimage.png')
I guess you used something like
out = imwrite() ;
No imwrite doesn't give you any ouput, it writes your matrix into the filename and format which you have specified in the given folder.
Damian Wierzbicki
Damian Wierzbicki 2017년 7월 6일
yes, I was doing that. Thank you so much. But now, even when I do it as I should have been doing, it displays a white rectangle
KSSV
KSSV 2017년 7월 6일
What data does matrix have? Attach it.
Damian Wierzbicki
Damian Wierzbicki 2017년 7월 6일
The file is too big to attach it. The entries of the matrix are integers ranging from 100 to above 1000 if that helps ?
Thorsten
Thorsten 2017년 7월 6일
편집: Thorsten 2017년 7월 6일
Imwrite assumes double input data to be in the range [0, 1]. Everything above 1 will be mapped to 1, resulting in an all-white image. So you have to map your data to the range [0, 1].
Damian Wierzbicki
Damian Wierzbicki 2017년 7월 6일
Thank you Thorsten, used mapminmax to map my data to desired range, not sure if that's what you meant ? It now displays the image ok, but with horizontal black thin lines ? There are also, hardly visible, white thin vertical lines along the image ? Any idea what might be causing it ?

댓글을 달려면 로그인하십시오.

Image Analyst
Image Analyst 2017년 7월 6일

0 개 추천

Try this:
storedStructure = load(filename) % Don't use semicolon
% Now extract the image field into its own variable.
rgbImage = storedStructure.myImage; % Or whatever the field for the image is called.
imwrite(rgbImage, 'my RGB image.PNG');

댓글 수: 1

Damian Wierzbicki
Damian Wierzbicki 2017년 7월 6일
Thank you. I get the same using this method, a white rectangle.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

질문:

2017년 7월 6일

댓글:

2017년 7월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by