Creating RGB images from .Mat arrays with imaginary entries
显示 更早的评论
I have a series of .mat files which contain raw image data that is unscaled and contains imaginary entries. I can display these images by loading the .mat and then using imagesc(abs(file(:,:,#))); where # indicates a single positive integer. This properly displays the scaled image, but I cannot do any operations on the image. Creating a handle such as img1 = imagesc(...) and then using imwrite to create an RGB image does not work and imread tells me that I need to imput a string as the target but then I cannot get the modulus with abs or reference a single 2-d array, which results in a matrix dimensions error. What is the best way to read from a .mat slice and convert it to a scaled rgb image?
回答(2 个)
Sean de Wolski
2011-5-19
You could extract just the real components using:
doc real
or just the imaginary ones using
doc imag
E.g.
Irgbreal = real(Irgb);
6 个评论
Christopher
2011-5-19
Sean de Wolski
2011-5-19
That's a good reason to avoid both of those!
Do you have the Image Processing Toolbox?
If so:
imtool(Irgbreal);
%You can adjust the contrasts and the values are the pixel intensities, not pseudocoloring.
What does the imaginary component look like? Do you need to do some operation on the two components?
Sean de Wolski
2011-5-19
And pulling just file(:,:,5) will be gray scale 2-dimensional.
In order to have it be RGB, you need an R&G&B component: e.g. file(:,:,1:3);%1->R,2->G,3->B
Christopher
2011-5-19
Christopher
2011-5-19
Sean de Wolski
2011-5-19
No it is not. If you are pulling just one slice of it, it has no G/B components. You may be visualizing it as an RGB image with some pseudocolor, but it does not have enough information to be RGB.
Christopher
2011-5-19
0 个投票
2 个评论
Sean de Wolski
2011-5-19
I would leave it as grayscale unless you need to impress some lawyers or politicians ;)
The intensity map is the information you have so you might as well view it as such in grayscale.
Christopher
2011-5-19
类别
在 帮助中心 和 File Exchange 中查找有关 Images 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!