Thread Subject: Doubly Linked Lists of objects

Subject: Doubly Linked Lists of objects

From: rebecca donnelly

Date: 7 Nov, 2009 18:28:01

Message: 1 of 3

Hi,
I am a first year PhD student and am implementing the image processing algorithm "Seeded Region Growing" as an exercise to help me get to grips with Matlab and to gain a deeper understanding of the algorithm.

The paper asks for a datastructure they call a "Sequentially Sorted List", it needs to hold an object which contains the x and y coordinates of a pixel and another value called Sigma which the list is sorted by.

I attempted to do this using the following code:

 % Calculate sigma and create a new pxladrs object
        sigma_value = abs(seg_img(x+1, y) - mean_gl);
        p = pxladrs(sigma_value);
        % Add x and y coords to pxladrs object
        p.Xvalue = x+1;
        p.Yvalue = y;
        % Add object to SSL
        if counter==0
            ssl_start = dlnode(p);
        else
            cur = ssl_start;
            % Insert ordered by sigma value
            while cur ~= 0
                if p.Sigma < cur.Data.Sigma
                    ssl_insert = dlnode(p);
                    ssl_insert.insertBefore(cur);
                    break
                end
         end
                cur = cur.Next;

However this didn't work as I couldn't store the pxladrs object in the doubly linked list.

Error:
??? Undefined function or method 'dlnode' for input arguments of
type 'pxladrs'.
Error in ==> SeededRegionGrowing at 58
            ssl_start = dlnode(p);

So my question is; How do I modify the doubly linked list so it can handle objects? Or am I going about this totally the wrong way?

Any comments appriciated,
Rebecca

Subject: Doubly Linked Lists of objects

From: Matt Fetterman

Date: 7 Nov, 2009 20:56:01

Message: 2 of 3

"rebecca donnelly" <rdonnelly10@qub.ac.uk> wrote in message <hd4e7h$ak2$1@fred.mathworks.com>...
> Hi,
> I am a first year PhD student and am implementing the image processing algorithm "Seeded Region Growing" as an exercise to help me get to grips with Matlab and to gain a deeper understanding of the algorithm.
>
> The paper asks for a datastructure they call a "Sequentially Sorted List", it needs to hold an object which contains the x and y coordinates of a pixel and another value called Sigma which the list is sorted by.
>
> I attempted to do this using the following code:
>
> % Calculate sigma and create a new pxladrs object
> sigma_value = abs(seg_img(x+1, y) - mean_gl);
> p = pxladrs(sigma_value);
> % Add x and y coords to pxladrs object
> p.Xvalue = x+1;
> p.Yvalue = y;
> % Add object to SSL
> if counter==0
> ssl_start = dlnode(p);
> else
> cur = ssl_start;
> % Insert ordered by sigma value
> while cur ~= 0
> if p.Sigma < cur.Data.Sigma
> ssl_insert = dlnode(p);
> ssl_insert.insertBefore(cur);
> break
> end
> end
> cur = cur.Next;
>
> However this didn't work as I couldn't store the pxladrs object in the doubly linked list.
>
> Error:
> ??? Undefined function or method 'dlnode' for input arguments of
> type 'pxladrs'.
> Error in ==> SeededRegionGrowing at 58
> ssl_start = dlnode(p);
>
> So my question is; How do I modify the doubly linked list so it can handle objects? Or am I going about this totally the wrong way?
>
> Any comments appriciated,
> Rebecca

I think you have to define the dlnode object as described in the documentation, it is not a built-in Matlab object.

classdef dlnode < handle
   properties
      Data
   end
   properties (SetAccess = private)
      Next
      Prev
   end

Subject: Doubly Linked Lists of objects

From: rebecca donnelly

Date: 10 Nov, 2009 11:10:19

Message: 3 of 3

No thanks to you lot I have solved the problem.

All that needed to be done was to copy the @dlnode folder to the root folder of the m file which need to use it.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
linked list rebecca donnelly 7 Nov, 2009 13:29:04
object rebecca donnelly 7 Nov, 2009 13:29:04
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com