Is that possible? The use case is needing to (without human intervention) find a spot to superimpose a stamp (small image).
I could just add space to the bottom of the page (like all my competition) but doing so shrinks the page (loses pixels) when printing. I would like to tout a better final product.
Any suggestions in approach would be most appreciated.
Thanks,
Kurt
Automatically detecting an area of white space
-
- Posts: 13
- Joined: Fri Mar 27, 2020 6:21 pm
Re: Automatically detecting an area of white space
Hi Kurt,
Thanks for your question here.
This highly depends on the variety of document layouts you have, the size you want to set the stamp and other configurations.
Without talking about complexity, I can tell you we have the technology for you to achieve this.
First of all we have methods such as 'IsBlank' that allows you to determine if a selected area in your image is blank:
https://www.gdpicture.com/guides/gdpict ... Blank.html
If you have no information to start your search for this blank area then perhaps getting the pixel RGB data and storing it into an array would be a good start. Then you can process this data based on your search and find an area which is limited to only RGB values you accept:
https://www.gdpicture.com/guides/gdpict ... teger.html
https://www.gdpicture.com/guides/gdpict ... yByte.html
This is but a single approach and you may find an alternative.
Other approaches may also be viable however I am not fully aware of your constraints so you will need to adjust how much processing is required based on what you already know about the input documents and overall expectations.
I would suggest browsing here to find all our imaging solutions:
https://www.gdpicture.com/guides/gdpict ... mbers.html#
Let me know if this helps.
Regards,
Hugo Cudd
Technical Support
Thanks for your question here.
This highly depends on the variety of document layouts you have, the size you want to set the stamp and other configurations.
Without talking about complexity, I can tell you we have the technology for you to achieve this.
First of all we have methods such as 'IsBlank' that allows you to determine if a selected area in your image is blank:
https://www.gdpicture.com/guides/gdpict ... Blank.html
If you have no information to start your search for this blank area then perhaps getting the pixel RGB data and storing it into an array would be a good start. Then you can process this data based on your search and find an area which is limited to only RGB values you accept:
https://www.gdpicture.com/guides/gdpict ... teger.html
https://www.gdpicture.com/guides/gdpict ... yByte.html
This is but a single approach and you may find an alternative.
Other approaches may also be viable however I am not fully aware of your constraints so you will need to adjust how much processing is required based on what you already know about the input documents and overall expectations.
I would suggest browsing here to find all our imaging solutions:
https://www.gdpicture.com/guides/gdpict ... mbers.html#
Let me know if this helps.
Regards,
Hugo Cudd
Technical Support
-
- Posts: 13
- Joined: Fri Mar 27, 2020 6:21 pm
Re: Automatically detecting an area of white space
Thanks, yes I've gotten it to work by basically creating rectangles on one corner and working my way across and up or down until I find a good spot. Doesn't take too long ...
private bool IsRegionEmpty(int imageID, Rectangle region)
{
using (GdPictureImaging gdPictureImaging = new GdPictureImaging())
{
gdPictureImaging.SetROI(region.Left, region.Top, region.Width, region.Height);
double blackPixelCount = gdPictureImaging.CountColor(imageID, System.Drawing.Color.Black);
gdPictureImaging.ResetROI();
return blackPixelCount == 0;
}
}
private bool IsRegionEmpty(int imageID, Rectangle region)
{
using (GdPictureImaging gdPictureImaging = new GdPictureImaging())
{
gdPictureImaging.SetROI(region.Left, region.Top, region.Width, region.Height);
double blackPixelCount = gdPictureImaging.CountColor(imageID, System.Drawing.Color.Black);
gdPictureImaging.ResetROI();
return blackPixelCount == 0;
}
}
Who is online
Users browsing this forum: Semrush [Bot] and 0 guests