필터 지우기
필터 지우기

How to change the size of a image, which is saved as a .mat file?

조회 수: 4 (최근 30일)
Gulfam Saju
Gulfam Saju 2022년 3월 16일
댓글: Walter Roberson 2022년 3월 18일
load e15802s13_P50176.7.h5.mat;
I have this image. I want to change the size/dimension of the image from this mat file. How can I do that?
  댓글 수: 5
Gulfam Saju
Gulfam Saju 2022년 3월 18일
I want the dimension to be 256*256*8
Walter Roberson
Walter Roberson 2022년 3월 18일
Your input has:
  • input dimension #1 has size 20
  • input dimension #2 has size 640
  • input dimension #3 has size 20
  • input dimension #4 has size 640
You want 256 x 256 x 8 output.
Which of the input dimensions should correspond to your output dimension #1, size 256?
Which of the input dimensions should correspond to your output dimension #2, size 256?
Which of the input dimensions should correspond to your output dimension #3, size 8?
What should happen to the 4th input dimension? For example are you wanting to take mean() over a dimension? max() over a dimension ("Maximum Projection" is a real thing and sometimes very useful) ?

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

답변 (1개)

DGM
DGM 2022년 3월 16일
Since a .mat file can contain any number of things, I'm going to have to assume that:
  • you know what's in the file and how to open it
  • the content is something which can be handled with existing image processing tools
  • you know how you want to save the file and how to save it
... in which case the answer is incredibly generic:
Open the file, resize the image(s) with imresize(), and then save the result in whatever way you intend.
  댓글 수: 1
Walter Roberson
Walter Roberson 2022년 3월 16일
If the .mat file contains a figure that has an image displayed inside it, then you can use imhandles() https://www.mathworks.com/help/images/ref/imhandles.html on the figure to get the handles of the image() objects. Then you can access the CData property to get the data.
(You might also need to cmap = colormap(ancestor(ImageHandle, 'axes')) in order to get the color map. And in some cases you might need to caxis(ancestor(ImageHandle, 'axes')) in order fetch the color mapping properties.)

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

Community Treasure Hunt

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

Start Hunting!

Translated by