Creating RGB images from .Mat arrays with imaginary entries

1 view (last 30 days)
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?

Answers (2)

Sean de Wolski
Sean de Wolski on 19 May 2011
You could extract just the real components using:
doc real
or just the imaginary ones using
doc imag
E.g.
Irgbreal = real(Irgb);
  6 Comments
Christopher
Christopher on 19 May 2011
for my .mat file, (:,:,5) is an rgb image, not a gray scale
Sean de Wolski
Sean de Wolski on 19 May 2011
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.

Sign in to comment.


Christopher
Christopher on 19 May 2011
I just figured out that the matrix file(:,:,#) is actually an intensity map that is just being colormapped (red corresponding to highest values, blue to lowest) by imagesc, but I am still stuck on converting this to a usable image file. I suppose the easiest thing would be to use the intensity map to give a grayscale image. How should I go about that. Sorry I'm not very familiar with Matlab as is probably obvious.
  2 Comments
Sean de Wolski
Sean de Wolski on 19 May 2011
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
Christopher on 19 May 2011
well I need to eventually be able to segment the image, so I guess I'll just drag along the intensity map after using abs to get rid of the imaginary values, then use imfilter, etc. for gradient mapping.

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!