rgb_sum for mutiple images
1 回表示 (過去 30 日間)
古いコメントを表示
i ve a code for calculating rgb_sum value of a region in an image . now i want to run this for number of images but its giving error. here is the code for one image.
I=imread('C:\Users\ASUS\Desktop\ref_LB\g20.tif');
I=double(I);
rgb_sum=0;
[c r]=imfindcircles(I,[10 30]); c=round(c);
c1=c(1,2);
c2=c(1,1);
for i=-5:5;
for j=-5:5;
rgb_sum=rgb_sum+I(c1+i,c2+j);
end
end
its working properly for single image but when im trying it for series of images like here the code for multiple images-
for i=1:20;
file_name=strcat('C:\Users\ASUS\Desktop\ref_LB\g',num2str(i),'.tif');
I=imread(file_name);
I=double(I);
rgb_sum=0;
[c(i) r]=imfindcircles(I,[10 30]);
c=round(c);
c1=c(1,2);
c2=c(1,1);
for k=-5:5;
for j=-5:5;
rgb_sum(i)=rgb_sum+I(c1+k,c2+j);
end
end
end
its giving error; In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in reftest (line 11) [c(i) r]=imfindcircles(I,[10 30]); same for rgb_sum(i).
how to get them all in a single matrix . can anybody help me please..?
0 件のコメント
採用された回答
Michael Haderlein
2015 年 2 月 13 日
編集済み: Michael Haderlein
2015 年 2 月 13 日
[c(i) r]=imfindcircles(I,[10 30]);
Do you need the c of every image in the end? Or will you need it only temporarily in the loop? If you need it only inside the loop, change it to
[c r]=imfindcircles(I,[10 30]);
Otherwise, you have to index c with
[c(:,:,i),r]
as it is a matrix.
In any case, in this line
rgb_sum(i)=rgb_sum+I(c1+k,c2+j);
you need to write
rgb_sum(i)=rgb_sum(i)+I(c1+k,c2+j);
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!