Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: function output
Replies: 1   Last Post: Jun 9, 2011 1:54 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Forrest

Posts: 19
Registered: 8/25/08
function output
Posted: Jun 8, 2011 10:28 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello, I need some help with a little project. I must split a program into dedicated functions for each task. There are two functions. The first function converts the RGB image into BW. The second function should allow the selection of a point with the mouse on the BW image returned by function 1, and output the point's coordinates. I haven't had any success yet.
Can someone guide me please?
Thanks in advance!

Here is the code:

>function mediere(I)
>% I este o imagine
>global BW;
>gray=rgb2gray(I);
>figure, imshow(gray), title('imaginea obtinuta dupa rgb2gray');
>AVG = medfilt2(gray, [5 5]); %se calculeaza o medie cu pixelii vecini
>figure, imshow(AVG), title('imaginea obtinuta dupa medfilt2');
>BW=im2bw(AVG, graythresh(AVG));
>figure, imshow(BW), title('imaginea obtinuta dupa graythresh');
>end



>function [] = coordonate(k)
>% k - input image
>% draw circle on image
>% image=imread('onion.png');
>% coordonate(image);
>figure;
>imshow(k);
>pt = ginput(1)
>r = 15 ;
>x1 = pt(1,1);
>y1 = pt(1,2);
> x2 = x1;
> y2 = y1 + r;
> xpt = [x1 x2];
> ypt = [y1 y2];


>for i=1:size(k,1)
> for j=1:size(k,2)
> x2 = j;
> y2 = i;
> val = floor(sqrt((x2-x1)^2 + (y2-y1)^2));
> if(val == floor(r))
> nim(i,j,1) = 255;
> nim(i,j,2) = 0;
> nim(i,j,3) = 0;
> else
> nim(i,j,1) = k(i,j,1);
> nim(i,j,2) = k(i,j,2);
> nim(i,j,3) = k(i,j,3);
> end
> end
>end


>uint8(nim);
>figure;
>imshow(nim);
>%line(x,y);
>line(xpt,ypt);
>end



This is the main:
>close all
>IM = imread('proba1.png');
>global BW;
>mediere(IM)
>coordonate(BW)



Date Subject Author
6/8/11
Read function output
Forrest
6/9/11
Read Re: function output
Pekka

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.