bufferedimage

Converting Red, Green and Blue to RGB

隐身守侯 提交于 2019-12-13 09:22:04
问题 first I get Red, Green and Blue value from the following code, BufferedImage image; File input = new File("digital_image_processing.jpg"); image = ImageIO.read(input); width = image.getWidth(); height = image.getHeight(); for(int i=0; i<height; i++){ for(int j=0; j<width; j++){ Color c = new Color(image.getRGB(j, i)); int red = (int)c.getRed(); int green = (int)c.getGreen() ; int blue = (int)c.getBlue() ; Here After Getting the Red, Green and Blue value from getRGB(), I want to Do some

Image perspective correction

亡梦爱人 提交于 2019-12-13 08:48:06
问题 I need to rotate my BufferedImage on 3 axis (x, y and z), by the angles given in 3 integers. Is there any native methods in java? If not, how would I achieve that? Update #1: I've done some of it with OpenCV... Will update when finished! Update #2: Since this was just a part of my project, I realized that solving just a part of the problem wouldn't be good, so I used OpenCV getPerspectiveTransform() and then warpPerspective() methods from Imgproc class to transform image. I have basically

Create BufferedImage from YBR_FULL Dicom Image

懵懂的女人 提交于 2019-12-13 07:14:29
问题 I want to Create BufferedImage from YBR_FULL Dicom Image to view it over a JPanel in my program, can any one tell me how to deal with this type of Dicom file?also can we convert from YBR_FULL to RGB? if yes how ? 回答1: You should convert the YBR values to RGB. here's a page on how to convert between YBR and RGB 来源: https://stackoverflow.com/questions/15873867/create-bufferedimage-from-ybr-full-dicom-image

Convert BufferedImage TYPE_INT_RGB to OpenCV Mat Object

一曲冷凌霜 提交于 2019-12-13 06:04:09
问题 I am storing BufferedImages inside a MySQL database and retrieve them to a java application. The BufferedImages are of type TYPE_INT_RGB. How can i convert that image to a OpenCV Mat object? I do always get a java.lang.UnsupportedOperationException: Mat data type is not compatible: Exception. Can somebody help? 回答1: Got it on my own. int[] data = ((DataBufferInt)image.getRaster().getDataBuffer()).getData(); ByteBuffer byteBuffer = ByteBuffer.allocate(data.length * 4); IntBuffer intBuffer =

Exception in thread “Thread” java.lang.OutOfMemoryError: Requested array size exceeds VM limit

戏子无情 提交于 2019-12-13 05:58:55
问题 The only thing difference is there is two different crop location. The question is why i get this error?? Method call CropRealOriginalImage1 orderName = new CropRealOriginalImage1(); FourAreaCropAgain1 orderNameFirst=new FourAreaCropAgain1(); orderNameFirst.orderNameFirst(); Decode decode= new Decode(); decode.inputImage("C:/TEMP/Image/Embed Image/Four Area/OrderFirst.png"); if(decode.s.equals("")){ System.out.println("OderFirst=null"); }else{ //put b into txt file System.out.println("decode

How to find different shades of a color in Java?

♀尐吖头ヾ 提交于 2019-12-13 04:51:03
问题 If I have the RBG code of a number, such as -16777216 (black), how can I find other similar shades of black using this color code? I'm trying to convert an image to monochrome by marking all pixels which are not -16777216 to be white. However, often there are varying shades of black which are found, but they are lost because they are not an exact match. Edit: I'm having a bit of trouble. When I try to use this color to find shades of black, so I can ignore them while converting the other

Serialize Obj with 2 BufferedImage transient fields, second image won't be read

一个人想着一个人 提交于 2019-12-13 04:34:08
问题 before explaining my thing i want to mention that i haven't tried-search any alternate solutions (which i am pretty confident something will be found). I am just pretty curious to know why this is happening. So...I have an object that has 2 transient buffered images fields (firstimage and second image like the following example). Since bufferedimage does not implement serializable, one way to serialize them (i found in SO) is this. I did the exact same thing and everything worked perfect for

Java JComponent.getGraphics() always returns null

一笑奈何 提交于 2019-12-13 04:25:14
问题 I am trying to an object that functions as a button but uses images for display. My problem is that when call getGraphics() it returns null . I have been searching allover the place and cannot find why? My code for the constructor where it dies at is... public class ImageButton extends javax.swing.JComponent implements java.awt.event.MouseListener { private static BufferedImage DEFAULTBUTTON; private BufferedImage button; private Graphics g; public ImageButton(){ //Call the constructor for

Drawing Shapes with lines on a transparent Graphics2D to get a png image

不羁的心 提交于 2019-12-13 03:38:35
问题 So my goal is to have a window that opens where you can draw some lines on a white background by just clicking. The problem is that when it try to save it always comes back as a png, but it comes as a square image. If I draw a triangle with my lines I get a triangle inside a white square but I want the triangle only. I would really appreciate any help I tried every solution I came accross on stackoverflow and I tried to understand Graphics2D in depth but sadly failed public class Draw{ public

Rendering multi-line multi-page formatted text to a BufferedImage (not in Android)

爱⌒轻易说出口 提交于 2019-12-13 03:34:06
问题 I've just had to implement the creation of a PNG Image, rendering out the contents of a text file. Searching online I found a few implementations using Android but no complete example for multi-line text using standard Java only so thought it would be worth posting my solution here. The requirements were: Take a String of potentially any size and render it out with properly formatted paragraphs to fit into PNG images, splitting the String into lines and paragraphs properly. If the rendered