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 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Guillaume
am 29 Jun. 2018
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
am 29 Jun. 2018
[m, n] = size(crop);
[q,z] = size(crop);
i = 1 ; %column
j = 1 ; %row
%
figure(1),imshow(crop);
hold on;
s = 0 ;
Antworten (1)
Walter Roberson
am 29 Jun. 2018
[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().
Siehe auch
Kategorien
Mehr zu Image Segmentation and Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!