Problem with cell array and mat2gray
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
lena kappa
am 11 Sep. 2022
Kommentiert: Walter Roberson
am 12 Sep. 2022
Hi everyone i have written the next code that reads multiple images whose names start with specific numbers and then does some changes to those images
clc; clear;
outLoopValues = number;
for k = 1 : numel(outLoopValues)
index = outLoopValues(k);
outLoopValues2 = size;
for r = 1 : numel(outLoopValues2)
index2 = outLoopValues2(r);
thisBaseFileName = sprintf('%d.%d0.png', index2, index);
thisFileName = fullfile(folder, thisBaseFileName);
images{index2, index} = imread(sprintf('%d.%d0.png', index2, index));
I1{index2, index} = images{index2, index}(:,:,1);
Icrop{index2, index} = imcrop(I1{index2, index},[1 1 100 100]);
Inew = Icrop(~cellfun('isempty', Icrop));
inpsur1{index2, index}=double(Icrop{index2, index});
Idetrended=mat2gray(inpsur1');
I=uint8(255*Idetrended);
I1=imadjust(I);
I2 = medfilt2(I1,[3 3]);
z=I1;
end
end
but i get the next error:
Error using mat2gray
Expected input number 1, A, to be one of these types:
logical, uint8, uint16, uint32, int8, int16, int32, single, double
Instead its type was cell.
does anyone know how can i fix this?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 11 Sep. 2022
Idetrended = cellfun(@mat2gray, inpsur1', 'UniformOutput', 0);
I = cellfun(@im2uint8, Idetrended, 'UniformOutput', 0);
I1 = cellfun(@imadjust, I, 'UniformOutput', 0);
I2 = cellfun(@(img) medfilt2(img, [3 3]), 'UniformOutput', 0);
Several of those steps can be combined if you do not have a use for the intermediate variables.
7 Kommentare
Walter Roberson
am 12 Sep. 2022
%one combined step
I2 = cellfun(@(rgbimg) mefilt2(imadjust(im2uint8(mat2gray(rgbimg))), [3 3]), inpsur1.', 'uniform', 0)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Convert Image Type finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!