I'm trying to split an 350x450x50 image into 350x400x10 and i'm getting the following error while saving the .tif file

>> I_d = double(imread('abcde.tif'));
>>b1 = I_d(:,:,1:10);
>>X = reshape(b1,size(b1,1)*size(b1,2),10);
>>[n m] = size(X);
>>AMean = mean(X);
>>AStd = std(X);
>>B = (X - repmat(AMean,[n 1])) ./ repmat(AStd,[n 1]);
>>[V D] = eig(cov(B));
>>cumsum(flipud(diag(D))) / sum(diag(D));
>>PC = B * V;
>>var(PC);
>>VReduced = V(:,3);
>>PCReduced = B * VReduced;
>>PCReduced * VReduced';
>>Z = ((PCReduced * VReduced') .* repmat(AStd,[n 1])) + repmat(AMean,[n 1]);
>> d = permute(reshape(X, 350, 10, 400), [1 3 2]);
>> e = permute(reshape(Z, 350, 10, 400), [1 3 2]);
>> X_1 = uint8(d);
>> Z_1 = uint8(e);
>> imwrite(X_1,'1-10.tif')
*Error using writetif (line 40)
Writing TIFFs with 10 components is not supported with IMWRITE. Use Tiff instead. Type "help Tiff" for more information.
Error in imwrite (line 472)
feval(fmt_s.write, data, map, filename, paramPairs{:});*

Answers (1)

It is not possible to imwrite() TIFF with more than 3 channels. You need to use the Tiff() class and choose one of the several different ways that TIFF can store additional data.

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Asked:

on 9 Mar 2016

Answered:

on 9 Mar 2016

Community Treasure Hunt

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

Start Hunting!