I have the following image
So, i was trying to use tesseract to get hocr and then detect the bounding area of text to get the ends of the page. But, for the above image, even after the border rectangle there is some text which is making tesseract to detect the text and which in turn is not helping me to get the border rectangle coordinate.
What i am actually trying to do is to crop the image based on the border(outer rectangle). Is there a way to get he coordinates of the outer rectangle using java. Also, if there are multiple rectangle's, is there a way to specifically get the bottom-right rectangle corner. Is this possible to do using OpenCV ?
Related
I have an image consisting of background image with multiple colors and text on it.
I have done OCR and i have recognised the text and bounding box surrounding the text.
Now i want to get all the pixels surrounding the text inside the bounding box and store it in a matrix.
I am using opencv for image processing and opengl for rendering (Rajawali).
Any help would be appreciated.
Thanks in advance.
I need to crop an Image in irregular shape my app, i.e., I select a portion by finger and if I click crop button, the selected portion alone in the Image will be saved in SDCard.
How to achieve it?
You have to define a Path for the Shape you want to be cut out.
Then create a rectangle around it an set everything between your shape an the rectangle to transparent (Alpha Channel)
This source here should give you some hints:
https://github.com/lvillani/android-cropimage/blob/develop/src/com/android/camera/CropImage.java
Take a look at the onSaveClicked method, line 209
Refer this project:
https://github.com/coderush/FlexiCrop
It has the code to crop irregular shapes.
I'm looking for an automatic way to grab a piece of a bitmap and extract a certain part of it.
Let me explain:
If I have this image:
http://imgur.com/B9U9E
It has a big white border. (see link for better white result) I'm looking for a way to only grab the dialog above. So no white borders around the dialog. Is there a way to do this by code or with a library?
You should know that the image could have any form and positioned anywhere on the white dialog.
So a user draws something on the white panel and i need the program to automatically make a rectangle about where the users drew on the canvas and save that bitmap where the user drew on the canvas (Everything in between that rectangle).
Pseudocode
Define the background color.
Scan from the left, right, bottom, top and store the locations of the transitions from background to drawing.
The rectangle defined by (left, bottom) and (right, top) defines the cropping area
For a Java code example, please see: How to auto crop an image white border in Java?
Look into Bitmap.createBitmap.
Well i have a circle image that i am using imageview to show in the app
I need someway to make parts of this image interactive like event should fire depend on which part of the image the user is clicking , i.e. if user is clicking on the center of the image or on one of the pie slices of the circle image
how this could be achived ?!
One way would be slicing the image into the parts, then assigning a clickevent to each part with the appropriate reaction.
the other way could be to check on the clickevent where you have clicked (x,y) and check if it is in a range you defined as an area if it's in there.
or you have different colors of the slices, you then get the color of the clicked pixel and evaluate where it belongs to
I am developing a small program which cuts images by the color.
That's will be easiest to explain using this example image:
And I want to create a new image just with the purple form, without the black frame.
Does anyone have any ideas? I am using Java 2D so I think that I need to create an Object "Shape" with the purple area of the first image.
If the image is literally like the one you show, you could:
load the image into a BufferedImage (with ImageIO.read())
create a new BufferedImage of the same size, ensuring it has an alpha layer (e.g. set its type to BufferedImage.TYPE_4BYTE_ABGR)
"manually" go through each pixel in turn in the loaded BufferedImage, getting the pixel colour with getRGB() and checking if it's black
if the colour is black, set the corresponding pixel to transparent in the new image, else to the original colour from the first image (see setRGB() method)
save the new image (with ImageIO.write())
There are fancier ways, but this simple method is nice and understandable and will work fine for images of the type you showed.
You need to use some flood-fill algorithm that finds the boundries of the purple area:
Wikipedia has a page on it with excellent pseudo code and animations.
http://en.wikipedia.org/wiki/Flood_fill