how i divide n images present in a folder into 4 equal parts

1 回表示 (過去 30 日間)
Anamika baruah
Anamika baruah 2014 年 6 月 20 日
コメント済み: Image Analyst 2014 年 6 月 21 日
srcFiles=dir('fruits\*.jpg'); for i= 1:length(srcFiles)
Filename=strcat('fruits\',srcFiles(i).name);
I=imread(Filename);
imshow(I)
[x,y, z]=size(I)

回答 (2 件)

David Sanchez
David Sanchez 2014 年 6 月 20 日
Filename=strcat('fruits\',srcFiles(i).name);
I=imread(Filename);
imshow(I)
[x,y, z]=size(I)
I_1 = I(1:x/2,1:y/2,:);
I_2 = I(x/2+1):end,1:y/2,:);
I_3 = I(1:x/2,(y/2+1):end,:);
I_4 = I(x/2+1):end,(y/2+1):end,:);
  2 件のコメント
Anamika baruah
Anamika baruah 2014 年 6 月 21 日
it gives error
Image Analyst
Image Analyst 2014 年 6 月 21 日
Nice of you to share the full error message. I'd guess that the error is because x is an odd number and x/2 is a fraction, like 123.5.
For x/2 use xMid
xMid = floor(x/2);
Then for x/2+1 use xMid+1

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


Dishant Arora
Dishant Arora 2014 年 6 月 20 日

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by