How can I get to read the pixels in an image?
Please see details of my code below. What I am doing is trying to obtain the pixels for an image. there is an initial image of a certain size, which is then split into smaller portions.
The problem I'm getting is that pixels can not be read past the middle of the original image. I hope I have explained this so it can be understood. I have included the class that I am working on
* To change this template, choose Tools | Templates
* and open the template in the editor.
package MandelbrotConstruction.compression;
import java.awt.*;
import java.awt.color.ColorSpace;
import java.awt.geom.AffineTransform;
import java.awt.image.*;
import java.io.*;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
* @author Charlene Hunter
public class DisplayImg extends JPanel {
private static BufferedImage image;
private static ArrayList<Range> rangeLot;
private static ArrayList<Domain> domainLot;
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
int w = MainFrame.getJPanel1().getWidth();
int h = MainFrame.getJPanel1().getHeight();
Graphics2D g2 = (Graphics2D) g;
File img = MainFrame.getImgFile();
image = null;
if (img != null) {
try {
image = ImageIO.read(img);
//filter the image with a grayscale
ColorConvertOp grayOp = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
image = grayOp.filter(image, null);
//scale image to the size of the panel
AffineTransform at = new AffineTransform();
at.scale(256.0 / image.getWidth(), 256.0 / image.getHeight());
AffineTransformOp resizeOp = new AffineTransformOp(at, null);
image = resizeOp.filter(image, null);
ArrayList<Range> r = createRanges(image, 3);
ArrayList<Domain> d = createDomains(image);
int i = 0;
for (Domain dom : d) {
System.err.println("this is " + i);
System.out.println(dom.getPixels());
i++;
CompareClass comparer = new CompareClass(r, d);
} catch (IOException e) {
System.err.println("IOException");
g2.drawImage(image, null, 0, 0);
public static ArrayList<Range> createRanges(BufferedImage bi, int divisions) {
int w = bi.getWidth();
int h = bi.getHeight();
rangeLot = new ArrayList<Range>();
int k = (int) Math.pow(2, divisions);
for (int x = 0; x < w; x = x + (w / k)) {
for (int y = 0; y < h; y = y + (h / k)) {
BufferedImage range = bi.getSubimage(x, y, w / k, h / k);
double[] pix = range.getRaster().getPixels(x, y, range.getWidth(), range.getHeight(), (double[]) null);
Range r = new Range(x, y, range, pix);
rangeLot.add(r);
return rangeLot;
public static ArrayList<Domain> createDomains(BufferedImage bi) {
int w = bi.getWidth();
int h = bi.getHeight();
domainLot = new ArrayList<Domain>();
int step = 4;
for (int x = 0; x < w - step; x = x + step) {
for (int y = 0; y < h - step; y = y + step) {
BufferedImage domain = bi.getSubimage(x, y, 2 * step, 2 * step);
double[] pix = domain.getRaster().getPixels(x, y, domain.getWidth(), domain.getHeight(), (double[]) null);
Domain d = new Domain(x, y, domain, pix);
domainLot.add(d);
return domainLot;
}If what I have included is not sufficient, please let me know. the problem is only arising when the pixels are being obtained for the subimage
Thanks
Hi, the error message I am getting is (i'm printing out the x,y values and width and height so that I can see what going on) the whole image is 512x512, and I am grabbing pixels for squares of 64x64, but when it gets to 256 it throws an exception. I don'd understand why
(x: 0, y: 0)
width: 64, height: 64
done!
(x: 0, y: 64)
width: 64, height: 64
done!
(x: 0, y: 128)
width: 64, height: 64
done!
(x: 0, y: 192)
width: 64, height: 64
done!
(x: 0, y: 256)
width: 64, height: 64
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
at java.awt.image.ComponentSampleModel.getSampleDouble(ComponentSampleModel.java:807)
at java.awt.image.SampleModel.getPixels(SampleModel.java:823)
at java.awt.image.Raster.getPixels(Raster.java:1613)
at MandelbrotConstruction.compression.DisplayImg.createRanges(DisplayImg.java:83)
at MandelbrotConstruction.compression.DisplayImg.paintComponent(DisplayImg.java:51)
at javax.swing.JComponent.paint(JComponent.java:1006)
at javax.swing.JComponent.paintChildren(JComponent.java:843)
at javax.swing.JComponent.paint(JComponent.java:1015)
at javax.swing.JComponent.paintChildren(JComponent.java:843)
at javax.swing.JComponent.paint(JComponent.java:1015)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:559)
at javax.swing.JComponent.paintChildren(JComponent.java:843)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4979)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4925)
at javax.swing.JComponent.paint(JComponent.java:996)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
at java.awt.Container.paint(Container.java:1709)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
at sun.awt.RepaintArea.paint(RepaintArea.java:224)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)
at java.awt.Component.dispatchEventImpl(Component.java:4060)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Window.dispatchEventImpl(Window.java:1791)
at java.awt.Component.dispatchEvent(Component.java:3819)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Similar Messages
-
adobe reader xi i am running 2 display screens and when i have a file open and go to print the print page opens on my second screen. How can I get adobe reader to just display on one screen?
I want the capability of adobe reader to just run on one screen.I had the same problem.
Try this.
https://igppwiki.ucsd.edu/groups/publichelpwiki/wiki/a1538/Howto_Disable_Acrobat _as_the_Safari_PDF_Viewer.html -
How can I get Acrobat Reader X to send my pdf to the printer?
My pdf just looks at me while I push all of the buttons, file menus and keyboard shortcuts associated with printing and it does nothing. No dialog box, no nothing. All three of my printers work and i've tried them all. It just doesn't do anything. Any suggestions? I really need help here.
From: Pat Willener [email protected]
Sent: Monday, July 30, 2012 9:16 PM
To: vinniereed
Subject: How can I get Acrobat Reader X to send my pdf to the printer?
Windows 7; Acrobat Reader 10.0; local and online.
Thanks,
Vinnie
Re: How can I get Acrobat Reader X to send my pdf to the printer?
created by Pat Willener <http://forums.adobe.com/people/pwillener> in Adobe Reader - View the full discussion <http://forums.adobe.com/message/4588698#4588698 -
I want to switch to the u.s store as I now live in the us, I cannot switch stores because my balance is $1.41 in the oz store and needs to be zero, how can I get rid of the $1.41 when everything costs more or less than that? I do not have a credit card on the oz iTunes account an I cannot use my us one to top it up.
HELPClick here and request assistance.
(60992) -
how can i get acsess to my data if my iphone is shut and can´t open any more??how can i get acsess to the memory card????please help
You can't. There is no memory card. It uses flash memory that's soldered to the logic board. If you didn't back it up, your data is gone.
-
How can I get rid of the dark area on top one third of my iphone screen which spoils my background image?
It seems this problem is caused by the software to increase the readibility of upper letters (clock battery etc.) It be nice to leave us the control of choosing background letter color too if we are using brighter images or darker images.
I'm using iphone 4s and it appeared after I updated to new patch. 7.1.1.
Thanks,
Cem
I do not know how to move topics from sections of forum so I apologise for duplicate post.
https://discussions.apple.com/message/25594879#25594879Photo added.
-
I have an iPhone 6 with IOS 8.1.3. When I go to the landscape view in Safari, the bookmark page appears and takes up one half of the screen. How can I get rid of the bookmark page so I can use the whole screen to what I am browsing?
OOPS! Too quick on the trigger to ask that question without trying anything. Sorry. Solved it by touching the bookmark icon.
-
How can I get rid of the accumulation of the backups in the Macintosh HD of my new MBA 13.3'' ?
My best advice is that you stop worrying about the backups that TimeMachine is making on your MBA. First, these local backups are only made when TimeMachine should perform a backup but your computer isn't connected to TimeMachine. Once you reconnect your computer to TimeMachine it makes a backup and the local backups are deleted. Second, TimeMachine stops making local backups when your free drive space dips below 80%. So the local backups aren't going to take over your computer.
-
How can i get rid of the small box in the middle of my screen
How do i go about getting rid of the box in the middle of my screen that offers stuff like webify and to sign up to you guys. i really hate that box being there.
one more question " how do i go about getting the rid of the restore session box everytime i close my home page, i dont want to restore at times i just want to close my home page and when i open it up be at my home page.Ok, I fixed it, thank you but I still have another question I set google to be my main screen but now I have about 3 search bars one in the middle of the screen and to on top. My question to you is how can I get rid of the middle search bar on the google screen and just have the two on top?
-
I have a new iPad. I am using Comcast as my email provider but when I send a message, it pulls up the facebook email addresses for my contacts instead of the addresses stored in my comcast account. How can I get rid of the Facebook email addresses? The comcast addresses are stored in the comcast (xfinity) app. I do not use the "mail" or "contacts" apps ....I go straight to comcast (xfinity). I wish I could start over!!! thanks.
iPadI could be wrong, but it sounds like Facebook imported to your contacts. I have the Xfinity app on my new ipad, too, but none of my stored contacts from the online version are showing, only what I manually entered into the iPads contacts are there. When I did add the FB app, I did not grant it permission to push and pull from my ipad (not a fan of FB knowing every detail about me), so that may be where our difference lies. You could try to open the app and change your privacy settings, or delete it and then reinstall without granting permissions to integrate.
I'm sure someone here with a lot more knowledge then me can probably diagnose your issue better, though. Good luck! -
I have 2 accounts in my family and would like to purchase some of the same songs for both accounts, however when I try to purchase a duplicate song from the second account the song says play instead of purchase. How can I get some of the same songs?
Drrhythm2 wrote:
What's the best solution for this? I
Copy the entire /Music/iTunes/ folder from her old compouter to /Music/ in her account on this new computer. -
Since I synced my ipad to my iMac I have duplicate photos appearing in the Photo section on my iPad and one can be trashed but the other one can't. How can I get rid of the ones without the trashcan?
Thanks so much. I was afraid to mess with that. But when I unsynced them, it worked.
-
How can I get rid of the Flash Drive password?
I have recently purchased a 16Gb USB stick. When I plugged it in (Win 7 Ultimate) it came up as enhanced storage and I created passwords.
Now I cannot use it on Vista or Xp computers. On vista I right clik and select unlock but nothing happens. On XP the it shows up as removable disk and when I click on it it ask to insert disk.
How can I get rid of the password - in win 7 icant have a blank password for itHey,
In your case i would contact Toshiba memory support. You can give them a call or write an e-mail, have a look on Toshiba memory page:
http://www.toshiba-memory.com/en/service_support.html
Have you created the password using U3T software? On the same Toshiba page there is a FAQ article how to remove U3T Launchpad software. -
How can you get back to the registration screen to change information once registration is complete
how can you get back to the registration screen to change information once registration is complete?
You don't have to. Just go to Apple's Express Lane and add products.
-
After installing Itunes 10.6.3 When ever I start the computer I get a pop up the says "Applesyncnotifier.exe- unable to locate component, this application has failed to start because Corefoundation.dll was not found" How can I get rid of the pop up?
I hope it doesn't effect how I down load my itunes to my ipod and iphone.
No you should be fine. (The MobileMe service is being shut down, anyway, so there should be no impact at all.)
Maybe you are looking for
-
Hi, How VC is integrated in QM . Please mention the complete cycle with tcode. Thanks Jaya
-
Nice MOV from Screen Recording - Import to iMovie looks degraded
Hi, I am wondering why I have a great MOV file from a Mac screen recording program, with audio, and this looks fantastic when viewed with Quicktime. Then I import into iMovie and it looks much degraded. I don't use iMovie a lot, but I figured MOV qua
-
Hi guys, While i entering Shipping point, Delivery date in vlo1 transaction code for creation of delivery. It is giving message that delivery has not been create. Please give me suggestion Kasi
-
I use WIN7, PSE11, LR5 - 'Edit In' PSE11 does not open photos.
I use WIN7, PSE11, and LR5. LR5's 'Edit In' preference does not open my photos for editing in PSE11. What must I do to use PSE11 as an external editor?
-
HTTPS for posting incoming Invoices
Currently our vendors are using HTTP to post XML invoices to our XI server. But one of our vendor cannot use HTTP, they have to use HTTPS. So what should we do in our system so our vendor can post invoices to XI server by using HTTPS? do we need do e