Annotation Measurement Units
-
- Posts: 14
- Joined: Fri Jan 20, 2012 8:18 am
Annotation Measurement Units
Hi,
I am using Annotations to allow a user to select an area that is then used later to Zonal OCR.
Up to now, when working with the positions on the image, the values that I get for things like Page Width are in the 1000's. Now when I check the Top, Left, Width and Height of the Annotation, I find that the values are incredibly small. A possition of 5 is in the middle of the page. So how do I translate these position so that I can then use them to do the Zonal OCR?
Robert
I am using Annotations to allow a user to select an area that is then used later to Zonal OCR.
Up to now, when working with the positions on the image, the values that I get for things like Page Width are in the 1000's. Now when I check the Top, Left, Width and Height of the Annotation, I find that the values are incredibly small. A possition of 5 is in the middle of the page. So how do I translate these position so that I can then use them to do the Zonal OCR?
Robert
Re: Annotation Measurement Units
Hi,
Just scale the inch size by the image resolution.
IE:
Kind regards,
Loïc
Just scale the inch size by the image resolution.
IE:
Code: Select all
int widthPixel = Math.Round(widthInches * horizontalResolution);
int heightPixel = Math.Round(heightInches *verticalResolution);
Loïc
-
- Posts: 14
- Joined: Fri Jan 20, 2012 8:18 am
Re: Annotation Measurement Units
Hi Loic,
I have done the following to workout the exact pixels of the image where the annotation is:
HorizontalResolution = imageViewer.HorizontalResolution
VertialResolution = imageViewer.VerticalResolution
PixTop = AnnotationTop / VertialResolution
PixHeight = AnnotationHeight / VertialResolution
PixWidth = AnnotationWidth / HorizontalResolution
PixLeft = AnnotationLeft / HorizontalResolution
I then draw a rectangle:
oGdPictureImaging.DrawRectangle(ImageID, PixLeft, PixTop, PixWidth, PixHeight, 10, Color.Red, True)
Now when I reposition the annotation with these fixures, it is where it should be. But if draw a rectangle on this image using these figures, the rectangle is off to the left and slighly down. It is not in the same position as the Annotation. Now the GD Viewer has functionality that enables you to select what area you want to process. But using the Rectangle Annotation provides a really nice way of enabling the user to edit the size and position of the area. So I am trying to integrate the two so that I can then process the area selected.
So my question is, how do I translate the position of the Annotations so that I get an accurate rectangle on the image?
I have done the following to workout the exact pixels of the image where the annotation is:
HorizontalResolution = imageViewer.HorizontalResolution
VertialResolution = imageViewer.VerticalResolution
PixTop = AnnotationTop / VertialResolution
PixHeight = AnnotationHeight / VertialResolution
PixWidth = AnnotationWidth / HorizontalResolution
PixLeft = AnnotationLeft / HorizontalResolution
I then draw a rectangle:
oGdPictureImaging.DrawRectangle(ImageID, PixLeft, PixTop, PixWidth, PixHeight, 10, Color.Red, True)
Now when I reposition the annotation with these fixures, it is where it should be. But if draw a rectangle on this image using these figures, the rectangle is off to the left and slighly down. It is not in the same position as the Annotation. Now the GD Viewer has functionality that enables you to select what area you want to process. But using the Rectangle Annotation provides a really nice way of enabling the user to edit the size and position of the area. So I am trying to integrate the two so that I can then process the area selected.
So my question is, how do I translate the position of the Annotations so that I get an accurate rectangle on the image?
Re: Annotation Measurement Units
Hi,
Please have a look on the reference guide.
Especially here:
Hope this helps.
Kind regards,
Loïc
Please have a look on the reference guide.
Especially here:
So the top-left corner of the annotation bbox is:Left: Left position, in inches, of the middle point of the bounding box of the annotation.
Top: Top position, in inches, of the middle point of the bounding box of the annotation.
Width: Width, in inches, of the bounding box of the annotation.
Height: Height, in inches, of the bounding box of the annotation.
Code: Select all
topLeftX = annot.Left - annot.Width/2
topLeftY = annot.Top - annot.Height/2
Kind regards,
Loïc
Re: Annotation Measurement Units
Since Horizontal and VerticalResolution are "Pixels per inch" and Left, Top, Width, Height are all in inches...shouldn't your calculation to convert to pixels look like this:
HorizontalResolution = imageViewer.HorizontalResolution
VertialResolution = imageViewer.VerticalResolution
PixTop = AnnotationTop * VertialResolution
PixHeight = AnnotationHeight * VertialResolution
PixWidth = AnnotationWidth * HorizontalResolution
PixLeft = AnnotationLeft * HorizontalResolution
Just a thought
-C
HorizontalResolution = imageViewer.HorizontalResolution
VertialResolution = imageViewer.VerticalResolution
PixTop = AnnotationTop * VertialResolution
PixHeight = AnnotationHeight * VertialResolution
PixWidth = AnnotationWidth * HorizontalResolution
PixLeft = AnnotationLeft * HorizontalResolution
Just a thought
-C
Who is online
Users browsing this forum: No registered users and 2 guests