Cropping 3D image into equal size
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Fadhurrahman
el 24 de En. de 2022
Editada: Fadhurrahman
el 26 de En. de 2022
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 comentarios
Respuesta aceptada
Matt J
el 25 de En. de 2022
Editada: Matt J
el 25 de En. de 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 comentarios
Matt J
el 25 de En. de 2022
Does "extracting" mean something different to you then just addressing the cell?
Acell{i,j}
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!