How can crop and display a character in an image without using mouse?
The image contain only a one charater and nothing else.
Example a scanned copy of a paper, which contain a character drawn on it.
This will require some image processing, and there is a lot of libraries available for this task. General processing sequence would be:
convert image to b&w image
calculate integral image over it
using integral image determine glyph boundaries
( if nothing of the above make sense to you, read some image processing books first )
You could get Slick2D library and then use the SpriteSheet class to crop it. It works like this:
SpriteSheet s = new SpriteSheet("imagelocation");
Image cropped = s.getSubImage(x,y,width,length);
Worked for me :D
Related
I'm working on this project now. I used there snapshot method on object of Text class. Then I'm able to use PixelReader class for read every pixel of WritableImage. On the right is image of letter created by snapshot method, and on the left is pixel visualisation of this letter.
My problem is that quality of image on the right is very poor (it's raster graphics). Is any way to convert String or Text object into image which is vector graphics and then use on it pixel reader?
I'm sorry if my questions are basics, but I'm new in Java. Maby are other possibilities to make this effect from picture better ? Thanks for every advice.
So, say I have two images, one which is a .bmp of some text and another which is a bufferedImage, how would I go about finding if the .bmp is inside the bufferedImage?
Im really lost on how to find an image within an image, a color is easier as its just one thing to search for but an image seems much harder...
One Solution to this Problem is "Template Matching".
This means sliding your Template (the image you want to find) over the Image (you want to search in) and at every Position compare the similiarity of all Pixels.
The Position of your Template in the Image is at the Maximum this procedure returned.
As suggested in the comments you can use OpenCV for this Task which support Template Matching.
I am making an app for extracting number from image card using sample code of android-ocr(tesseract-ocr).
I have trained the data as per the card font. It is detecting few card if the card having unique background, but if the card having multi background (attached sample) then the number is not recognizing.
Even if the card number little overlapping the background then also not recognition.
I tried to use the steps below, to remove the background:
Smoothing the cropped image using:
GaussianBlur( crop, crop, Size(3,3), 0, 0, BORDER_DEFAULT );
cvtColor( crop, crop, CV_RGB2GRAY );
Edge detection used sobel:
crop = SobelEdgeDetect(crop);
Converting to bitwise not cv:
bitwise_not(crop,crop);
Used adaptiveThreshold to remove shadowed kind of things:
adaptiveThreshold(crop,crop,255,CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY,75,10);
After using these steps I am getting the image (attached bar-Process`png, citi1-Process.png, citi-Process.png), which is coming bold with blank space inside the number. In this case the ocr application is not recognize the number.
I do not know how can fill these number with bold letter.
Now the big challenge for me to remove the background from any image card with out disturbing the text part of the card. So please suggest me how can I overcome all the above issue specific how can remove the background of the image`
I have attached few sample & output data for your reference.
Thanks & regards
Anil
I got this exception when my app is trying to read a JPG image using ImageIO.read( ) method. This exception is not thrown for all jpg file.
I found this answer useful Intersection of bands in R raster package, but still it converts my colored image to a black n white one. I guess that question has focused on the right issue, but I want it to keep my image colored(not black and white).
Download image: https://skydrive.live.com/?cid=19547371C4F3B839&id=19547371C4F3B839%21105
Simply if someone can obtain a BufferdImage from the image given that's enough (should not convert the image to gray scale one).
You are a genius if you can answer this :D.
Plz help.
That is typically the exception you get when Java cannot read the JPEG file. While they are standard compliant JPEGs Java has not implemented the full standard. I recommend converting the JPEG file with ImageMagick, Irfanview, or something like this before actually trying to open it in Java.
You may use ImageJ, which can deal with most JPEGs.
I want to create an android app that takes 2 pictures (taken from the phone camera). Takes the top part of pic1 and the bottom part of pic2 and combines them to the final picture.
I'm thinking about converting each image to byte array. Then take the half values from the array of the first image and the other half from the other image, merge them in the final array and convert that array back to image. Is it feasible? Is this a good solution or there is any better practice for this?
Well I guess I found the solution. There is a class in the Java6 API called "BufferedImage". This class has the methods: setRGB , getRGB where you can get the int value of the rgb color for the pixel you specify. This way you can get the pixel color from the image you want and set it in the target image.
Try using OpenCV. It will be very fast since it will be handling the images in native code. Convert Bitmap objects into Matrix(OpenCV) object and send the address to the native code where you can do these computations very easily. If any code is required, do let me know.