Need more documentation for image manipulation methods

Class library usage, coding and language questions.
User avatar
slavikf
Posts: 104
Joined: Mon Sep 13, 2010 9:07 pm
Location: Toronto, Canada
Contact:

Need more documentation for image manipulation methods

Post by slavikf » Sat Jan 29, 2011 1:38 am

Need more documentation for image manipulation methods

I use a lot of image comparisons and validations in my tests. And documentation is lacking some essential info. For example:
This page explains details about FindOptions method:
http://www.ranorex.com/Documentation/Ra ... ctor_4.htm

So, i need to set Imaging..Preprocessings and clipping (Rectangle) arguments. How i do that?
Clicking on Image_Preprocessings link brings me here:
http://www.ranorex.com/Documentation/Ra ... ssings.htm
where i can get some idea about that parameter, but still can't get clear understanding how to use it.

Even worse with Rectangle Clipping. It brings me to totally non-informative page, where i can't get any useful info, how to implement it:
http://www.ranorex.com/Documentation/Ra ... ipping.htm

Please, add more info.
Also, would be nice, if you add examples, how to call or use methods. Just like on MSDN:
http://msdn.microsoft.com/en-us/library ... indow.aspx

Another nice feature to copy from MSDN is "Community content" - mini-forum on every-method page, where developers can put their comments/questions/examples. I know MySQL has same feature, too.

User avatar
slavikf
Posts: 104
Joined: Mon Sep 13, 2010 9:07 pm
Location: Toronto, Canada
Contact:

Re: Need more documentation for image manipulation methods

Post by slavikf » Sat Jan 29, 2011 1:42 am

Oh, and please, provide me with example of calling FindOptions method with 3 arguments, mentioned above. I looked in user guide - found nothing on that matter... :-(
public FindOptions(
double similarity,
Imaging..Preprocessings preprocessing,
Rectangle clipping
)

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Need more documentation for image manipulation methods

Post by Support Team » Mon Jan 31, 2011 1:16 pm

Hello,

thanks for the hints regarding documentation.
For now when you need an example, you could have a look at the code that is generated by the recorder.
For .net, c# or VB specific information please consult Microsoft's documentation. You can also find a lot of examples in the internet.

A call to FindOptions could look like this:
new Imaging.FindOptions(0.95,Imaging.Preprocessings.Edges | Imaging.Preprocessings.Grayscale, new Rectangle(0,0,20,20));
Some samples are in the user guide, like this:
http://www.ranorex.com/support/user-gui ... ition.html

Regards,
Roland
Ranorex Team
.
Image

User avatar
slavikf
Posts: 104
Joined: Mon Sep 13, 2010 9:07 pm
Location: Toronto, Canada
Contact:

Re: Need more documentation for image manipulation methods

Post by slavikf » Tue Feb 01, 2011 6:54 pm

Hm, found strange behavior:

In the code below, i expect that element "repo.FormOIS_WinStation_11_EyeSca.Element59648Info" appears to be same as bitmap in "imageOrig", except that one or two pixels on the edges (frames). So i need to exclude edges. So:

This code FAILS:
Validate.ContainsImage (
	repo.FormOIS_WinStation_11_EyeSca.Element59648Info,
	imageOrig,
	new Imaging.FindOptions(1.0,Imaging.Preprocessings.None, new Rectangle (5,5,imageOrig.Width-10,imageOrig.Height-10)),
	"TC204: Validation: Original image restored after UNDO operation", false);
And this PASS:
Bitmap imageOrigPart=imageOrig.Clone( 
	new Rectangle (5,5,imageOrig.Width-10,imageOrig.Height-10),imageOrig.PixelFormat);
Validate.ContainsImage  (
	repo.FormOIS_WinStation_11_EyeSca.Element59648Info,
	imageOrigPart,
	new Imaging.FindOptions(1.0),
	"TC204: Validation: Original image restored after UNDO operation", false);
However, i understand that should be equal!
Seems like there is a bug in API...

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Need more documentation for image manipulation methods

Post by Support Team » Tue Feb 01, 2011 10:48 pm

slavikf wrote:However, i understand that should be equal!
No, the code snippets do different things (obviously :D ). As the API documentation for the Imaging.FindOptions.Clipping property explains, the clipping rectangle is always applied to the image in which the search takes place; that is always the first argument of all imaging methods. Consequently, the first code snippet crops the screenshot of item Element59648Info (taken at runtime) and the second code snippet crops the imageOrig bitmap.

By the way, you can also use the Imaging.Crop method to cut out the desired part of the imageOrig bitmap.

Regards,
Alex
Ranorex Team
.
Image