Filter löschen
Filter löschen

What happens when an image is first edited in Paint and then processed in Matlab?

1 Ansicht (letzte 30 Tage)
When I open an existing image (TIF) with Paint and do some corrections and save it, and open it with MATLAB, it gives me the error of exceeding dimension! Why? What happens in Paint? I checked it and see it turns a 2D image into 3D! why and how? How can I correct it? If I need to do some modifications in Paint before going to Matlab, what should I do to keep the dimensions?
Thanks so much. Steven

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 14 Dez. 2013
If the corrections were done in color, it would need to change it to RGB, which involves a 3D array.
If the corrections are in grayscale, it is possible that Paint is choosing to write the file in RGB anyhow. It has been a long long time since I used Paint, so I do not know if there is some option you could use for grayscale output.
If Paint is changing it to an RGB image, then you can apply rgb2gray() to it to change it back to grayscale.
  3 Kommentare
Walter Roberson
Walter Roberson am 14 Dez. 2013
If it shows up as N x M x 4 then it is saved as CMYK. In some of the other file formats one might guess it would be RGBA, but TIFF RGBA need special reading procedures and the x 4 is specifically documented for CMYK for TIFF files.
To do the conversion to RGB see the following (and just don't do the grayscale conversion): http://www.mathworks.com/matlabcentral/answers/96767-how-can-i-convert-my-4-channel-cmyk-image-data-to-gray-scale-for-image-processing

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 14 Dez. 2013
If im is your image, write
im=im(:,:,1)
  1 Kommentar
Walter Roberson
Walter Roberson am 14 Dez. 2013
If the file stored CMYK and the image is grayscale, you could try extracting im(:,:,4) . I am seeing discussions indicating that there may be some shifts if that is done.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by