I want to convert an image to dimension MxNx3 from MxNx4.

2 visualizaciones (últimos 30 días)
Akash Patil
Akash Patil el 7 de Sept. de 2016
Respondida: DGM el 22 de Sept. de 2024
For the tif image of size 289 x 289 x 4 I am not able to perform any operations such as imadjust, gray thresh etc. I am able to perform all these operations on other image with 256*256*3.
Need a way to do covert
  3 comentarios
Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran el 7 de Sept. de 2016
check with permute command
José-Luis
José-Luis el 7 de Sept. de 2016
What's on the 4 channels of the tif image?

Iniciar sesión para comentar.

Respuesta aceptada

DGM
DGM el 22 de Sept. de 2024
If you have a TIFF file, from which imread() returns a 4-channel image, then it's ostensibly a CMYK image.
If the image is legitimately a CMYK image, you can convert to sRGB or whatever colorspace using applycform(). Assuming the TIFF file contains an embedded color profile:
unzip peptiffs.zip % tiffs need to be zipped for the forum
% assuming the file has an embedded profile
iccin = iccread('pep_cmyk.tif'); % this profile is in the TIFF
iccout = iccread('sRGB.icm'); % the destination profile is part of IPT
% read the file
inpict = imread('pep_cmyk.tif');
% convert to sRGB
C = makecform('icc',iccin,iccout);
outpict = applycform(inpict,C);
imshow(outpict)
If the file does not have an embedded profile, you can use iccfind() or whatever profile you want to presume as the source profile.
Just because the file is apparently CMYK doesn't mean that's what's actually stored in it. If imwrite() is ever given a 4-channel image with a destination format of TIFF, it will write it as CMYK regardless of what those four channels mean in concept. I know I've seen "CMYK" TIFFs which were clearly not CMYK. I've created plenty which were RGBA.
inpict = imread('pep_rgba-as-cmyk.tif');
% split the image from RGBA to RGB+A
alpha = inpict(:,:,4);
inpict = inpict(:,:,1:3);
% imshow() doesn't mat transparent images
% but you can just compose the image with the axes background
hi = imshow(inpict);
hi.AlphaData = alpha;

Más respuestas (0)

Categorías

Más información sobre Image Filtering and Enhancement en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by