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.
Related
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.
Lets say I use a black key jpg image as my layout in Java Code. Is there an easy way to get the region out of an image so I can use region.Contains() for my onTouchListener?
I've looked for them and there isn't any. I ask this because Im making a piano app and would like to get the regions of the images I use for the black/white keys.
Rather than use an image, try rendering the piano keys yourself, and check if input is in the black key regions you render, rather than using an image.
If you really want to use the image, define the black regions within the image by hand.
Detecting regions in an image is a difficult problem, one you probably don't want to get into for such a simple purpose. If you had many images, or had to do this frequently it might be worth the headache but as you presumably don't... don't worry about it.
Was just wondering how you would be able to check each pixel, from top of your screen to bottom (or just a 500x500 rectangle) for a pattern of pixels in it. Example look through all the pixels, and see if there is 20 red pixels in a row (Search the screen for a red box).
Sorry for the terrible description, let me know and ill try to make it more specific.
What you are trying to do is called Template Matching in the Image Processing community, you should first check this.
For the implementation part, you can access the pixels of BufferedImage (using getRGB/getRGBs methods), or even better you can use JAI or JavaCV if you want to do anything serious.
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
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.