ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Selection intersection
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

spetric

Croatia
308 Posts

Posted - Mar 04 2015 :  14:03:21  Show Profile  Reply
Hi,

I have two questions regarding Selections.

1. Is there some option to create selections intersection?
Something like: Sel3 = Sel1 & Sel2 (such option would be helpful).

2. For checking if point is inside selection, what method is faster?
a) PaintView->SelectionMask->GetPixel(x, y) == 0
b) PaintView->IsPointInsideSelection(x, y)

TIA,
Siniša

xequte

38176 Posts

Posted - Mar 04 2015 :  21:16:27  Show Profile  Reply
Hi Siniša

1. No, but it is a good idea for a coming release

2. They are the same as PaintView->IsPointInsideSelection calls:

PaintView->SelectionMask->GetPixel(x, y) == 0

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Mar 05 2015 :  08:30:27  Show Profile  Reply
Thanks Nigel,

Until intersection implementation, there is a workaround:

bool selIntersect = true;
PaintView->LoadSelectionFromStream(sel1); 
selIntersect &= PaintView->IsPointInsideSelection(x, y);
PaintView->LoadSelectionFromStream(sel2); 
selIntersect &= PaintView->IsPointInsideSelection(x, y);


However, this seams a costly operation. Maybe it's better to
export (copy) selection masks and then perform AND operation between those two
masks. Resultant mask will be intersection and
SelectionMask->GetPixel(x, y) == 0 will give desired result.

Go to Top of Page

xequte

38176 Posts

Posted - Mar 05 2015 :  22:17:08  Show Profile  Reply
Sorry Siniša

I may be misunderstanding your request. What are the sources of your two selections? If they are in the same TImageEnView then they will automatically merge, so IsPointInsideSelection will return the correct result regardless of which selection.


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Mar 06 2015 :  01:55:29  Show Profile  Reply
Hi Nigel,

Yes, selections are merged, which means it's an union of two selections (Sel1 union Sel2), so the method IsPointInsideSelection will return true if point is inside Sel1 OR Sel2.

I'm trying to make an intersection of selections: Sel1 is visible and created by user, the other one, Sel2, is created programmatically and is not visible.
As there is no method to create intersection, I'm trying to achieve some kind of intersection of Sel1 and Sel2 and check if point is inside Sel1 AND Sel2.

So, I'm just thinking loudly, how to perform such task (mask depth = 8):

1. Copy user's SelMask of Sel1 into some external 8-bit bitmap (Mask1).
2. Save Sel1.
3. Programmatically create invisible selection Sel2 and save it's mask as external 8-bit bitmap (Mask2).
4. Restore Sel1.
5. Perform AND operation between bitmaps (masks): Mask1 = Mask1 AND Mask2.

Now, bitmap Mask1 contains intersection of selections and calling Mask1->GetPixel(x,y) will fulfill intersection query...I hope so.

Any other idea? It would be nice to reduce those steps.
Go to Top of Page

xequte

38176 Posts

Posted - Mar 08 2015 :  20:36:45  Show Profile  Reply
Hi

Yes, that would do it, but why not simply create the mask for the invisible selection using an in-memory bitmap rather than involving your TImageEnVect?

Another way would be simply to have a non-visible TImageEnVect for your second selection and simply call ImageEnVect1.IsPointInsideSelection() AND ImageEnVect2.IsPointInsideSelection(). That would be faster unless you are making a huge number of calls to IsPointInsideSelection.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: