Define 2 plotted lines in an image as variables inside a function in Matlab? -


product of code

function [yupper, ylower] = segmentation(a)         a=imread('g16.bmp');         ar=a(:,:,1);         [rows, columns] = size(ar);         avgs = mean(ar(50:165,:), 2);         avgs2 = mean(ar(165:315,:), 2);         [~,ind]= max(abs(diff(avgs)));         [~,ind2]= max(abs(diff(avgs2)));         figure, image(ar,'cdatamapping','scaled'); colormap('gray'); hold on;         yupper=plot([1 size(ar,2)], [ind+50 ind+50], 'r', 'linewidth', 2);         ylower=plot([1 size(ar,2)], [ind2+165 ind2+165], 'g', 'linewidth', 2);     end 

above code used segment grey scale images based on large instensity changes,i'm looking declare 2 plotted lines variables can carry out future processing. however, if type in whos , lines appear follows in table;

yl               1x1                     112  matlab.graphics.chart.primitive.line               yu               1x1                     112  matlab.graphics.chart.primitive.line 

if remove the plot commands receive errors associated brackets etc , if manipulate code further seems mess correctly plotted data, can help?

if want delete specific data figure can accessing xdata , ydata properties of figure handle. can in matlab r2014a or older by:

set(yl,'xdata',[]) set(yl,'ydata',[]) 

or in matlab r2014b or newer by:

yl.xdata=[]; yl.ydata=[]; 

example in r2013b:

clear;clc;  y=rand(20,1)*20; x=1:20; img=rand(20,20);  figure hold on image(img,'cdatamapping','scaled'); colormap('gray'); hp=plot(x,y);  % emulating code delay pause(2); set(hp,'xdata',[]) set(hp,'ydata',[]) 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -