infilename = 'C:/Users/DELL/Downloads/brains1.png';
Height=8; width=8;
currentimage = imread(infilename);
[r,c,~]=size( currentimage );
[~, currentfilename, ~] = fileparts(infilename);
for i=0:Height:r
ridx = floor(i/Height) + 1;
for j=0:width:c
cidx = floor(j/width) + 1;
if((i+Height)<r && (j+width)<c)
Image=imcrop(currentimage ,[(i+1) (j+1) Height width]);
outfilename = sprintf('%s_%03d_%03d.tif', currentfilename, ridx, cidx);
imwrite(Image, outfilename);
end
end
end

3 件のコメント

image-pro
image-pro 2021 年 10 月 19 日
Error in p8 (line 11)
Image=imcrop(currentimage ,[(i+1) (j+1) Height width]);
KSSV
KSSV 2021 年 10 月 19 日
編集済み: KSSV 2021 年 10 月 19 日
Specify the error.
After looking at your code, I feel you should read about blocproc.
image-pro
image-pro 2021 年 10 月 19 日
'imcrop' requires Image Processing Toolbox.

サインインしてコメントする。

 採用された回答

Image Analyst
Image Analyst 2021 年 10 月 19 日

1 投票

Instead of imcrop() you can use indexing:
Image= currentimage((j+1) : (j+Height), (i+1) : (i+width));

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Convert Image Type についてさらに検索

質問済み:

2021 年 10 月 19 日

回答済み:

2021 年 10 月 19 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by