I cant use other solutions such mentioned in other conversations because I dont have any time to understand them, so please help me with the same code
Error using imwrite Expected DATA to be non empty ???what is wrong with my code ???
5 ビュー (過去 30 日間)
古いコメントを表示
what is the problem and the solution of this problem . if I removed the line of imwrite it works and framing all the letters but I need to crop the letters and saves them for the next steps
while(j<m) while(i<n) rectangle('position',[i j 60 115] , 'LineWidth',1,'EdgeColor','red'); i= i+70; %45 i= i+1; ccc = imcrop(crop , [i j 60 115 ]); % str=sprintf('image%d.fig',i); % saveas(gcf,str); imwrite(ccc,strcat('hh',num2str(vv),'.bmp')); vv=vv+1; s=s+i; end j= j+120; %58 i= 1 ; j= j+1 ; end
4 件のコメント
Guillaume
2018 年 6 月 29 日
I dont have any time to understand them
So, you can't waste time trying to understand your problem, but it's ok for us to waste time doing the same?
Rik
2018 年 6 月 29 日
[m, n] = size(crop);
[q,z] = size(crop);
i = 1 ; %column
j = 1 ; %row
%
figure(1),imshow(crop);
hold on;
s = 0 ;
回答 (1 件)
Walter Roberson
2018 年 6 月 29 日
[m, n] = size(crop);
If you did that with an RGB image, then m would get assigned size(crop,1) and n would get assigned size(crop,2) * size(crop,3), and size(crop,3) is 3 for RGB images, so n would end up getting assigned 3 times the number of columns. You have while(i<n) so i would go to 3 times the number of columns. When you tried to crop beyond the actual number of columns, imcrop would return an empty array, and you would not be able to imwrite() the empty array.
Any time you are working with images that are not absolutely certain to be 2D (that is, you specifically converted them to grayscale, or you are reading from a file format that does not support color images), then you should be careful about how you use size().
参考
カテゴリ
Help Center および File Exchange で Image Segmentation and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!