Error using / Matrix dimensions must agree. during Gui Execution

2 visualizaciones (últimos 30 días)
sidra Rafique
sidra Rafique el 10 de Abr. de 2019
Comentada: sidra Rafique el 12 de Abr. de 2019
below code is for a pushbutton3. On click of the button this code should identify boundary and area calculation of the detected circle. but this code is displaying below error(screenshot attached) constantly. i dont know which matrix dimensions i have to correct.
global New_Image
btn4=getappdata(handles.RoiTag,'aadjusted'); % taken from pushbutton2
for ii=1:size(btn4, 1)
for jj=1:size(btn4,2)
pixel=btn4(ii,jj);
if (pixel>=0 && pixel<=100)
pixel=0;
else
pixel=255;
end
New_Image(ii,jj) = pixel;
end
end
Ball = New_Image(:,:,1) > 10;
Ball=~(Ball);
bw = imfill(Ball,'holes');
[B,L,~] = bwboundaries(bw,'noholes');
axes(handles.axes2);
% figure('Name',filename(a).name,'NumberTitle','off');
imshow(label2rgb(L,@jet,[0.5 0.5 0.5]));title('Area of the Circle');
% imshow(label2rgb(L,[]));title('Area of the Circle');
hold on
% myColorMap = jet(length(B));
for k = 1:length(B)
boundary = B{k};
% plot(boundary(:,2),boundary(:,1),'w',myColorMap(k,:),'LineWidth',2)
plot(boundary(:,2),boundary(:,1),'w','LineWidth',2)
end
stats=regionprops(L,'Area','Centroid', 'EquivDiameter');
threshold = 1;
for bound=1:length(B) % loop over the boundaries
boundary=B{k};% obtain (X,Y) boundary coordinates corresponding to label 'k'
% compute a simple estimate of the object's perimeter
delta_sq = diff(boundary).^2;
perimeter = sum(sqrt(sum(delta_sq,2)));
% obtain the area calculation corresponding to label 'k'
area=stats(k).Area;
% compute the roundness metric
metric = 4.*pi.*area./perimeter.^2;
% display the results
metric_string = sprintf('%2.2f',metric);
% mark objects above the threshold with a black circle
if gt(metric, threshold)
centroid = stats(k).Centroid;
plot(centroid(1),centroid(2),'ko');
end
text(boundary(1,2)-35,boundary(1,1)+13,metric_string,'Color','y',...
'FontSize',7,'FontWeight','bold')
setappdata(handles.ExtractTag,'area1',area);
end
waiting for kind response.
thanks
  2 comentarios
Adam
Adam el 11 de Abr. de 2019
What are the contents of L at the time of the error? You can use the Stop/Pause on Error option from the Breakpoints menu in the editor to have the code stop at the error and then use the Function Call stack to navigate back to the linie of your own code that triggered the error rather than the line in the jet function or wherever else it lands by default.
sidra Rafique
sidra Rafique el 12 de Abr. de 2019
its working.
i simply change the code from this
imshow(label2rgb(L,@jet,[0.5 0.5 0.5]));title('Area of the Circle');
to this.
imshow(label2rgb(L,jet,[0.5 0.5 0.5]));title('Area of the Circle');
Thanks

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by