Image processing with sub images
3 ビュー (過去 30 日間)
古いコメントを表示
Aravind Prabhu Gopala Krishnan
2021 年 8 月 12 日
コメント済み: Aravind Prabhu Gopala Krishnan
2021 年 8 月 12 日
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 件のコメント
DGM
2021 年 8 月 12 日
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?
採用された回答
DGM
2021 年 8 月 12 日
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
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Computer Vision with Simulink についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!