This question already has answers here:
How to capture an image in android with coordinates
(3 answers)
Closed 9 years ago.
Am new to work on bitmaps in android, and am unable to crop the image between four point ( clearly its not a rectangle in shape).
I convert the image into bitmap and set as background to layout.
now i have four different points(p0,p1,p2,p3)
I have the values of these points .
Now its time to crop the image between these region and show as rectangle shaped bitmap..(ie, as background to another layout.).
Am again mention clearly ,, crop the image between only these points..
ie, inside the region only.
Which way i can solve this problem,? can i use any third-party tool.. the suggest me which those ones.........
Thanks to #all
Here is a solution how to crop image if need a circle.
Based on that code, you can play a bit with Graphics and you will be able to crop your shape.
I will not write code ready for copy paste.
I hope it helps!
Edit:
Maybe Here is your solution!
At first select rectangle region with Bitmap.getPixels
Then avaluate lines which bound your shape.
Change evry pixel in pixels[] which is outsidebounds and set it to 0 (or other value, it will be background of image)
And recreate you image from new dataset.
EDIT: try to use clipping technics http://www.zetcode.com/gfx/java2d/clipping/ or http://www.roseindia.net/java/example/java/swing/graphics2D/clip-area.shtml in example rectangle was used but thos methodics allows any region
Related
I face this problem for a while and still cannot figure it out.
I'm using OpenCV and Java to detect the card from image and crop it then transfrom, every thing goes fine if the original image is in correct orientation. The task for now is: How to rotate image in 180 degrees? Or how to detect the text is upside down then we can rotate it to right orientation.
The result i get from OpenCV in Java is the Mat object contains the cropped cards.
Does anyone faced and solved this before or have any idea please direct me to the right solution.
Thanks in advance.
Here is sample images i cropped from originals
Sample 1
Sample 2
Just run your code, and if it finds nothing on the first pass then you can just rotate the image and try again? Or you could try scanning a small portion of the card only, and then you can determine if the card is the right way up or not.
It will pay to sit down and think it through for yourself on how this might be done best.
As for rotating images, have you tried looking it up? Because if you are using a buffered image then rotating can be done with a simple AffineTransform:
AffineTransform at = AffineTransform.getRotateInstance(Math.PI, image.getWidth()/2, image.getHeight()/2.0);
BufferedImage myRotatedImage = createTransformed(image, at);
Edit: For rotating a Mat object you can use:
Imgproc.warpAffine(Mat source, Mat dest, Mat M, Size size)
Taken from: http://docs.opencv.org/java/3.0.0/
I am not sure how to describe my questions headline to point out my question in one sentence (english is not my native language so please do not flame me for it)
I have the following szenario.
An image is displayed on a computer display. a camera (webcam or similar) is pointed towards the disolay so the image observed will cover nearly the whole video frame, but might be a bit disorted.
How can i calibrate/detect the bounds of the image?
For calibration purposes i could display a test picture. The camera and displayed image will NOT change its position after calibration!
My only idea would be to click some reference points with my mouse. Automatic detection like in QR code would be preferred/perfect.
You can use a calibration points similarly to QR code. Place three black squires in the calibration image corners. As the result you'll obtain an area (inside a rectangle, set by calibration points) that can be used as a boundary for all further images.
Hello I would like to know how I can clip off part of a texture that overlaps with another texture. Like the image below but without rendering part of the overlapped white "X". The octagon has an alpha transparency, i want to be able to see every thing under it except part of the overlapped white X.
Maybe this can help you
libgdx open gles 2.0 stencil alpha masking
It Looks like you Need to use a mask..
Another link, where I had my own Problem, where I used a depth buffer would be this here:
https://gamedev.stackexchange.com/questions/119821/libgdx-shaperender-within-a-circle-as-limitter/119869#119869
I hope this will help you furthermore.
I'm developing an image-processing program. And i'm stuck here.
I have an image like this:
I drew a closed line (path) by finger. Now, I want to get all points in the closed-region cut out from the image. Is there any algorithm or method?
How to create a circular ImageView in Android?
this may help you.
it user drawCircle() to crop a circle, maybe drawPath() can crop a region...
This question already has answers here:
How do I get a Raster from an Image in java?
(2 answers)
Closed 8 years ago.
I have been searching google for stuff like "Java Bitmap", "Create Java Bitmap", etc and cannot seem to find much information. From all of the code examples it looks like all of the bitmap libraries are third party or for android.
What I want to do is very simple. I want to create a small bitmap maybe 10x80, and be able to color each pixel at (x,y). I want to make a small I guess color bar that will show that position of items in a queue by color.
Are there any build in libraries to do this?
There's the java.awt.image.BufferedImage class. This has pixel-specific get/set methods.
http://docs.oracle.com/javase/7/docs/api/java/awt/image/BufferedImage.html
Here is an example of creating and writing to pixels with BufferedImage:
BufferedImage image = new BufferedImage(10, 80, BufferedImage.TYPE_4BYTE_ABGR);
image.setRGB(5, 20, Color.BLUE.getRGB());
The third parameter on the image is the type, which may vary based on your use, but for basic solid colors the one shown is good. The setRGB uses an int representation of the color so you can't just use a Color constant directly.
You probably don't want to use VolatileImage because the benefits are dubious in current Java implementations. See this stackoverflow question for why it may not help.
Look at the Oracle image turorial for help with this. It explains both your options and how to interact with them.