[RESOLVED] Separating list of points into different groups
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: [RESOLVED] Separating list of points into different groups

  1. #1
    Join Date
    May 2010
    Posts
    19

    [RESOLVED] Separating list of points into different groups

    In the program I am working on, we analyze the data of MRI scans. Sometimes, we want to draw boundaries around certain vessels in the brain.

    When creating an object boundary around two different vessels, it is normal to use two different objects.

    However, sometimes the second boundary is created under the same object name. This means that there are two separate boundaries that are technically just one object.

    I am trying to make a function that removes a region from one object, because currently the only option is to delete the object as a whole.

    The boundary is stored as a CList of CPoints, and these points only contain the actual boundary, not the points within the boundary. Here is an example output of the boundary points relative to the mouse:

    x: 269 y: 217 mouse: 234 217
    x: 260 y: 215 mouse: 234 217
    x: 261 y: 214 mouse: 234 217
    x: 262 y: 213 mouse: 234 217
    x: 263 y: 212 mouse: 234 217
    x: 265 y: 212 mouse: 234 217
    x: 266 y: 213 mouse: 234 217
    x: 267 y: 214 mouse: 234 217
    x: 268 y: 215 mouse: 234 217
    x: 260 y: 214 mouse: 234 217
    x: 261 y: 213 mouse: 234 217
    x: 262 y: 212 mouse: 234 217
    x: 266 y: 212 mouse: 234 217
    x: 267 y: 213 mouse: 234 217
    x: 230 y: 213 mouse: 234 217
    x: 229 y: 212 mouse: 234 217
    x: 229 y: 213 mouse: 234 217
    x: 229 y: 214 mouse: 234 217
    x: 230 y: 212 mouse: 234 217
    x: 230 y: 214 mouse: 234 217
    x: 231 y: 212 mouse: 234 217
    x: 231 y: 213 mouse: 234 217
    x: 231 y: 214 mouse: 234 217
    x: 230 y: 211 mouse: 234 217
    x: 232 y: 213 mouse: 234 217
    x: 229 y: 211 mouse: 234 217

    As you can see, about half way through, the points in the X column change drastically from 267 to 230. So, with a difference of over 35, it is obvious where the two regions could be separated.

    However, it is not always that easy. If the two regions are extremely close together, then the differences between the X and Y points would be almost impossible to differentiate between one region and another.

    As you can see at the top of the list of points, the X variable changes by a factor of 9 units, even though it is still a part of the same region. So if I had a second region less than 9 units away, then it would be seemingly impossible to tell the difference.

    Any ideas?

  2. #2
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,545

    Re: Separating list of points into different groups

    I think the answer is obvious, and you might not like it: if there is nothing in your list of CPointís that tells you where one object ends, you canít differentiate between objects simply looking at this list.
    When you draw those boundaries, could you somehow mark when mouseís button was down and when up?
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...

  3. #3
    Join Date
    May 2010
    Posts
    19

    Re: Separating list of points into different groups

    Quote Originally Posted by VladimirF View Post
    I think the answer is obvious, and you might not like it: if there is nothing in your list of CPointís that tells you where one object ends, you canít differentiate between objects simply looking at this list.
    When you draw those boundaries, could you somehow mark when mouseís button was down and when up?
    Well, this boundary drawing is done by "region growing" and just takes one mouse click, but thank you for saying what you did because I think I understand where you are going with that.

    The object clist is actually comprised of CPoint4d objects, and I just noticed that the cpoint4d.v variable was not being used in any of the algorithm, so in the Region Grow function, when it creates the final CPoint to be added into the list, I set cpoint4d.v to a unique float variable, thus signifying the end of the region!

    Thank you so much though, because I would not have thought of this without your post

  4. #4
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,545

    Re: Separating list of points into different groups

    Quote Originally Posted by dchaacke View Post
    Thank you so much though, because I would not have thought of this without your post
    You are very welcome!
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center