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

조회 수: 2 (최근 30일)
Akash Patil
Akash Patil 2016년 9월 7일
답변: DGM 2024년 9월 22일
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
Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran 2016년 9월 7일
check with permute command
José-Luis
José-Luis 2016년 9월 7일
What's on the 4 channels of the tif image?

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

채택된 답변

DGM
DGM 2024년 9월 22일
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;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Filtering and Enhancement에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by