The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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 ]

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;
>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');

>function [] = coordonate(k)
>% k - input image
>% draw circle on image
>% image=imread('onion.png');
>% coordonate(image);
>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


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

Date Subject Author
Read function output
Read Re: function output

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.