Cropping 3D image into equal size
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
So i wan't to crop all 594x397x7 with 5x5x7.
But there is problem when '594' reach the number of '190'. here is the code and error.
i tried switching 'for' command but it doesn't work
stackc=cat(3,R1, R2, R3, R4, R5, R6, R7)
[rows, columns, numberOfColorChannels] = size(stackc);
for i = 1:rows
for j = 1:columns
% for k = 1:numberOfColorChannels
% myVal = stackc(i,j,numberOfColorChannels);
c = images.spatialref.Cuboid([i,(i+4)],[j,(j+4)],[1,7]);
A{i} = imcrop3(stackc,c)
j+4;
i+4;
if j>190 && i==190;
j=0;
end
%save(['peak_col' num2str(i) '_row_' num2str(j) '.mat'],'A')
end
end
and this is an error
Error using imcrop3>validateCuboidBounds (line 140)
The crop window is out of bounds of the input volume.
The lower bound should be >= 1 and the upper bound should not exceed the image size.
Error in imcrop3>parseInputs (line 95)
isCuboidOutofBounds = validateCuboidBounds(V, xLimits, yLimits, zLimits);
Error in imcrop3 (line 44)
[V, xLimits, yLimits, zLimits, isCuboidOutofBounds] = parseInputs(varargin{:});
Error in croptest2 (line 29)
A{i} = imcrop3(stackc,c)
2 commentaires
Réponse acceptée
Matt J
le 25 Jan 2022
Modifié(e) : Matt J
le 25 Jan 2022
If the idea is to split A into cell array cells, using imcrop3 is a little over-elaborate. Consider using mat2cell or download mat2tiles from,
A=rand( 594 , 397 ,7);
Acell=mat2tiles(A,[5,5,7])
whos Acell
3 commentaires
Matt J
le 25 Jan 2022
Does "extracting" mean something different to you then just addressing the cell?
Acell{i,j}
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!