Image processing with sub images
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Aravind Prabhu Gopala Krishnan
el 12 de Ag. de 2021
Comentada: Aravind Prabhu Gopala Krishnan
el 12 de Ag. de 2021
Hello everyone here is my code which is breaking image of size 256x256 into subimages of 232^2 = 53800 subimage. But I need to adjust stride values and have to decrease the subimages to the range of 200 to 500 subimages. Here Stride is acting as 1 but i cannot adjust stride here. I cant use mat2cell or mat2tile in this project.
clc;
clear all;
SZ = 25;
M = 232;
N=232;
stepX = 3;
stepY = 3;
index_x = 0;
index_y = 0;
i = 0;
j = 0;
% blocks = cell(N,M);
img = imread('C:\Users\91894\Desktop\matlab\PNEUMONIA\person1_bacteria_1.jpeg');
img1 = imresize(img,[256 256]);
I = rgb2gray(img1);
blocks = cell(N,M);
for idx = 1 : N
for idy = 1:M
blocks{idx,idy} = I(idx:idx+SZ-1, idy:idy+SZ-1 , :);
end
end
montage(blocks.','Size',size(blocks),'BorderSize',[5,5])
4 comentarios
DGM
el 12 de Ag. de 2021
I don't know what exactly you're trying to do. I see a bunch of unused variables and then you make a padded montage of blocks. What part of the example doesn't suit what you want? Are you just trying to avoid using montage()? If so, why not just build the output directly in the loop?
Respuesta aceptada
DGM
el 12 de Ag. de 2021
I don't know if this is what you're after
I = imread('cameraman.tif');
SZ = 25;
stepsize = 3;
M = floor((size(I,1)-SZ+1)/stepsize);
N = floor((size(I,2)-SZ+1)/stepsize);
blocks = cell(N,M);
for idx = 1:N
for idy = 1:M
bx = 1+(idx-1)*stepsize;
by = 1+(idy-1)*stepsize;
blocks{idx,idy} = I(bx:bx+SZ-1, by:by+SZ-1 , :);
end
end
by:by+SZ-1 % note that the image isn't integer-divisible with this step size
Más respuestas (0)
Ver también
Categorías
Más información sobre Computer Vision with Simulink en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!