How to plot real time graph for images batch processing?
显示 更早的评论
How to plot the variable handles.sum_erode versus frame number,k in the following programming?
The graph should be able to update parallel with the frame by frame processing.
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
%button used to start the batch processing of the loaded video file------
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set (handles.pushbutton1 , 'enable' , 'off');
set (handles.pushbutton3 , 'enable' , 'off');
for k = 1 :1: handles.numFrames
gambar = handles.vidFrames(:,:,:,k);
set(handles.text8,'String',k);
imshow(gambar, 'Parent', handles.axes3);
drawnow;
handles.image=gambar;
red=handles.image(:,:,1);
green=handles.image(:,:,2);
blue=handles.image(:,:,3);
B=rgb2gray(handles.image);%RGB image convert image to grayscale image
%image processing(filtering and segmentation)
.
.
.
%using morphology
se=strel('disk', 5);
sel= strel('disk',1);
SE = strel('square',2);
clos_im=imclose(bw,se);
erod_im=imerode(clos_im,sel);
erod_im2=imerode(erod_im,SE);
imshow(erod_im2, 'Parent', handles.axes1);
drawnow;
figure,imshow(erod_im2) %show the processed image
%to plot histogram frame by frame
tgray= B.*uint8(erod_im2);
t=tgray(tgray>0);
ee=hist(t,0:255);
axes(handles.axes2),bar(ee);
drawnow;
handles.sum_erode=sum(sum(erod_im));
%coding to plot the real time graph but didn't workk!!
figure,hold on;
plot(k,handles.sum_erode );
drawnow;
pause(0.5);
end
回答(1 个)
Image Analyst
2015-4-12
k is only a single number, not a vector with the same length as handles.sum_erode, so you need to make it into a vector. Try this:
plot(1:k, handles.sum_erode, 'b-', 'LineWidth', 2);
xlabel('k', 'FontSize', 14);
ylabel('sum_erode', 'FontSize', 14);
grid on;
drawnow;
2 个评论
Syuhada Nurull
2015-4-14
Image Analyst
2015-4-14
You must have "hold on" somehow. Put
hold off;
cla reset
right before the plot to clear out any prior plots.
类别
在 帮助中心 和 File Exchange 中查找有关 Images 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!