Pixel by pixel image manipulation- java
Hey guys, i need to write a bit of code that looks at 3 images, assesses which pixels in ALL 3 are grey, and then redraws a new image consisting of the old ones, but grey only showing where all 3 have grey.
The inputs are mays with grey overlays, so therefore the output pixels should be the same UNLESS the pixel was grey in all 3.
I know its to do with arrays but im not a very good programmer and i need to get this done. Ive written the rest of my program, is anyone able to write this simple code? My problem is that i dont really know how to create an image using an array, plus also i know the pixel colours are stored awkwardly too. Ive only been programming in java for 4 weeks!
The BufferedImage class is really good at creating images from an array. I don't know what a may is, but if you had an array of integer values in the format {a, r, g, b, a ,r, g, b}, it would be as easy as this:
BufferedImage b = new BufferedImage(5, 5, BufferedImage.TYPE_4BYTE_ABGR);
b.getRaster().setPixels(0, 0, 2, 1, new int[] {128, 64, 32, 16, 128, 75, 50, 25});Hope this helps.
Similar Messages
-
Graphics2D.scale() producing pixelated images from vectors
I have a set of JPanels that I am using in my game to display the interface. Each one overrides paintComponent() and draws itself using Java2D. That all works great -- you can zoom in, move around, etc. and it all looks very nice and uses affine transformations.
I'm trying to produce very high resolution images from this interface (for use on a poster) and using scale() is creating pixelated images rather than nice, high res images of the vector data.
My code works as follows:
1.) Create an instance of the interface using some saved game state data.
2.) Create a Graphics2D object from a BufferedImage object.
3.) Scale the Graphics2D object so that the interface will fill the entire image (in my test cases, the interface is running at 800x600 normally, and the resulting image is going to be 3200x1600, so a 4x scale).
4.) Call the interface's paint method on the Graphics2D object. Note that all of the paint methods are using calls to fill... and draw...; nothing is getting rasterized in my code.
5.) Write out the image object to a file (PNG).
A sample of the output is here:
http://i176.photobucket.com/albums/w174/toupsz/ScreenShot2007-04-24_11-45-35_-0500.png
The white circle in the upper left hand corner is drawn in between steps 4 and 5. It actually looks correct.
Is there something I'm doing wrong? Is it a deficiency in Java itself? Is there some way to fix it?
Any help would be most appreciated!
Thanks!
-Zach
Message was edited by:
aaasdfTry setting a few hints on your Graphics2D:
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); -
IPhone 6 Pixelated images on instagram, pinterest and the icons on the app store
Hi!!! I have an iPhone 6, 64GB capacity. All the iOS updates are the latest ones. I'm getting pixelated images on instagram, pinterest and even the icons on the app store, I have tried to turn it of and off but it doesn't seems to work... any idea??.
Hi alex_h1!!!
i'm posting some of the images that are pixelated, I haven't noticed but that includes safari too... Here are some screenshots! I thought maybe it was the internet speed but the same thing happens even on wi-fi .
Thanks!!! -
iPhone 5 pixelated images in various apps problem- occurred within last 2 months and must be a result of apple network driver update
What's the fix?
Tried reset, restart, reboot, reopen of apps same problemWhat do you mean by reboot? Do you mean restore? Because if you haven't restored, then that's the next step. You'll need a computer with the latest version of iTunes and a USB connector.
For Mac:
http://support.apple.com/kb/PH12124
For PC:
http://support.apple.com/kb/PH12324 -
Pixelated images while playing back a video shot on my iPhone4s
Shot a video of my kid playing soccer and when watching on playback mode on either iphoto or imovie it comes out all pixelated images...
The size of the hard drive that the OS resides upon is not of concern as long as it has enough space for you operating system, the applications and a swap file.
The reason you NEED to keep you media files on a second drive is that it is TOO MUCH to ask of one drive to deal with all the system level read/writes AND to also seek, find and play all your audio AND video AND renders AND graphics and who knows what else you've got going.
to get the best possible playback.
1. Run Diskwarrior and Disk Utilities to make sure the files/directories are clean.
2 Disconect the system from any network.
3. Turn off any screen, power, disk power savers
4.Make the file self-contained
5. Have ONLY the external drive that the media resides upon connected through the firewire bus.
6.Shut down and reboot the machine before you start.
7. Pray.
Cheers,
x -
Pixelated images in safari, please help.
Hi everyone,
Hoping someone can help me with a issue i have with my new macbook pro.
When browsing the net, safari and firefox show really pixelated images. I thought it might be my internet connection compressing data or something, but i have tried other computers on the same internet connection and the images show perfect...
So this makes me think its the macbook. I have upgraded snow leopard from 10.6 to 10.6.2 and updated safari, but unfortunately this didnt help my problem. So now i have ended up here, asking you people, coz im out of ideas.
I will include some screen shots so you can see exactly what i mean.
Notice the bad quality images and even on google's banner it is pixelated heaps...
Please help if you can. Its very annoying. Cheers.
screenshots
http://i134.photobucket.com/albums/q93/Bonustokin/randon/Screenshot2010-02-13at1 00814PM.png
http://i134.photobucket.com/albums/q93/Bonustokin/randon/Screenshot2010-02-13at1 00814PM.pngYes, I see the big ugly squares. They are what appears whenever extremely heavy JPEG compression is applied to a low-resolution image tht has relatively large areas of similar colors. Something somewhere is applying such compression to the pages, or portions of them, that you are viewing in your browser(s). Your MBP is not doing that: it can't. Either the page images (or parts of them) are being compressed by the website owners or, if every web page is affected, they are being compressed by your ISP in the process of being transmitted to you, as Gordito suggests. That would greatly increase the speed of page loading, but at the expense of image quality. You wouldn't see the image degradation on an iPhone or cell phone — the screen is too small — but on the MBP's high-resolution display it would be much more apparent, IF the MBP were receiving the signal in the same highly compressed form as the phone. If the MBP receives the same web pages through an ISP that doesn't over-compress them, they'll look the way they ought to look. So if you are receiving these web pages through a cellular ISP rather than through a broadband connection, take the MBP to a wifi hotspot and connect through wifi instead. I bet things will look different then.
Compressing images is something a web browser can't do: a browser just displays the signal that comes to it. -
Photoshop CS6 (vs 13.0.1) Severely pixelated images
I have a iMac, running OS X Yosemite 10.0.1. Almost every time I open any files (RAW or Jpeg) I get severely pixelated images. I'm going from bridge to ACR to Photoshop or browser to Photoshop. it's intermittent. But extremely often. I can close the file and open it and sometimes it's just perfectly fine and sometimes it happens again. Any advice would be great. I keep all of my images on an external hard drive. I have 8 GB of RAM. All programs uptp date.
-trevee.Or, more likely, it's just the known video driver bugs in MacOS 10.10.
Apple is aware of the video driver bugs and working on a solution.
Until Apple can release a solution, you can disable GPU drawing in Photoshop's preferences and restart the app.
If you really need the GPU features in Photoshop, you may want to consider downgrading to a more stable version of MacOS. -
DNGs display as 256x192 pixel images
I picked up Aperture last night and installed the 1.5 update this morning. I imported a directory of DNG files (originally created using an Olympus E-500), and the files display as 256x192 pixel images. ACR correctly displays them as 3264x2448 pixel images. I flipped through the documentation and forums but didn't see any potential fixes. Aperture insists that the previews are up to date.
Any suggestions?
Thanks,
Andreas
MacBook Pro 2.0 GHz Mac OS X (10.4) 10.4.8Apple's Aperture pages state that "DNG files must be generated by the Adobe DNG Converter, with the "Convert to Linear Image" option turned off, and created from RAW formats that are otherwise already supported by Mac OS X 10.4.3 or later."
I followed those instructions to the letter in that I created the DNGs from E-500 raw files using Adobe's DNG Converter with that option disabled.
Perhaps Aperture is grabbing the embedded JPEG preview?
Cheers,
Andreas -
Useless code in java.awt.image.SampleModel.java?
Hey there,
i just looked up the sourcecode of java.awt.image.SampleModel.java in JDK 6
I discovered two issues i'd like to discuss.
1) on lines 736 to 739 this code is stated:
if (iArray != null)
pixels = iArray;
else
pixels = new int[numBands * w * h];
I asked myself, why does this code exist? while the getPixels() method is overwritten twice by double[] getPixels() and float[] getPixels, it is impossible to reach the part of the java code that initializes the pixels-array. One could only step into that line if "null" is given for the i/d/fArray-parameter. but if one would do so, the Java parser couldn't determine, which method is to use. so this part of code is just useless IMHO.
the java developers could get a little more performance out of this method if the if statement would be cut out - especially when reading a lot of very small rasters
or, on the other hand, they could replace this piece of code by an explicit bounds check.
When somebody touches this code, i would appreciate it if the errormessage "index out of bounds!" could be rewritten to be a little more verbose, like: Index out of bounds(x=123; y=456, maxX=100, maxY=400)!(numbers are just examples)
I hope i didn't miss something very basic and could help improving this class a little bit.
2) the local variable Offset(line 734) is coded against code conventions which say, variables shall start with a lowercase letter. Offset obviously doesn't fit that convention.
best regards
kdotOne could only step into that line if "null" is given for the i/d/fArray-parameter. but if one would do so, the Java parser couldn't determine, which method is to use. so this part of code is just useless IMHO. You can have
sampleModel.getPixels(x,y,w,h,(int[]) null, dataBuffer);No ambiguity on which method to use.
the local variable Offset(line 734) is coded against code conventions which say, variables shall start with a lowercase letter. Offset obviously doesn't fit that convention. You're correct, offset is against coding conventions. So are many other examples scattered throughout the jdk source code. For example, Hashtable should be called HashTable. In some cases the coding conventions might not have been established when the original code was written. In other cases it might have been human error. In yet other cases the conventions were probably ignored. The person who wrote the SampleModel class did so some 10+ years ago (Java 1.2). Who knows what he/she was thinking at the time, and in all honesty - does it really matter in this case?
Did you know there are some classes that declare unused local variables (ahem ColorConvertOp)? Some also have unused imports ( *** cough *** BufferedImage *** cough *** ). In essence, the jdk source code is not the epidemy of code correctness. But it's still pretty good. -
Runtime image manipulation using Flash
I would like to know if it's feasible to load an image (jpg,
gif, bmp and such) into Flash and then let the user modify it in
order to stretch, crop, adjusting contrast/brightness, removing
"red-eyes". I'm not aware of any image manipulation libraries in
Flash, which is why I'm asking this.well, here's the showResult method:
/**showResultImage() creates and shows results of manipulating pixels[]*/
public void showResultImage() {
int tempPixl;
int postOpWidth = postOpPixels[0].length;
int postOpHeight = postOpPixels.length;
int[] tempPix = new int[postOpHeight * postOpWidth];
for (int i=0; i<tempPix.length; i++) {
tempPixl = postOpPixels[i / postOpWidth][i % postOpWidth];
//create gray-level pixel. 0xFF makes it opaque.
tempPix[i] = 0xFF000000 | (tempPixl << 16) | (tempPixl << 8) | tempPixl;
} //End of i loop thru postOpPixels
resultImage = Toolkit.getDefaultToolkit().createImage(
new MemoryImageSource(postOpWidth,
postOpHeight, tempPix, 0, postOpWidth) );
scrollResultImage.remove(resultImagePanel);
resultImagePanel.remove(resultImageDisplay);
resultIcon = new ImageIcon(resultImage);
resultImageDisplay = new JLabel(resultIcon);
resultImagePanel.add(resultImageDisplay);
scrollResultImage.getViewport().add(resultImagePanel);
} /*End of showResultImage()*/ -
Display image in java.awt.List
hello guys,
How i can display image in java.awt.List means listbox. give me sample code. if you have
Waiting for your favorable reply.
Regards,
Bhavesh Kharwajava.awt.List you can not.
javax.swing.JLast you can. -
How to open and validate the tif images via java?
Is it possible to open and validating the photoshop images via java. Kindly advise me.
Thanks for looking into this.
Maria PrabudassI have recently looked at athe code for Image Processor.
To avoid bailing on errors it uses two techniques.
1) It turns off all PS error reporting in addition to just turning off dialogs with: app.displayDialogs = DialogModes.NO; (it restores the original settings when exiting)
2) It uses the Javascript construct Try.....Catch around the basic body of the code so "any" error will not abort the script but just jump to the "Catch" code.
Hope that is useful -
How to scale up and scale down a image in java
i have a problem i want to scale the any image in java
i mean that what i have to do actually when i scale up the image and scale down the image
plz reply as soon as possible
mail me at following address
[email protected]
[email protected]
[email protected]Look at Image.getScaledImage(...)
-
MBPro problems with image manipulation apps
My MBPro 15" 2011 never gave me any problem and I gotta say I am quite happy with it running any kind of app, recently, very recently, it often hangs up and requires many restarts to log in again, sometimes the grey screen stays still forever, some other times the screen shows stripes along the apple logo but most of all any time I open an image manipulation software it hangs up and fans start spinning a lot, it happens with PhotoShop and iPhoto but not with LightRoom (which is a 64bit app), tried to start a flight sim (the only game I have on the computer which also runs in 64bit) but same effect and it bothers me big time to have to backup it all and reinstall from scratch, any suggestion for problem source to look after?
thank you
GiovanniSounds like youre GPU is dead - symptoms match exactly. Check out the thread here - 2011 MacBook Pro and discrete graphics card.
https://discussions.apple.com/thread/4766577?tstart=0 -
How can I set the size of an image in java?
How can I set the size of an image in java? I have to choose the width and height of image...thanks to everybody...sorry for my english :-)
Hi 43477
Can you provide more details, do you want to setsize to display an image on a screen of when saving image etc?
PS.
There is a good invention called googlegoogle is good, but sometimes it's better to use more specific search, there is a search field avove on this page :)
Maybe you are looking for
-
How to authenticate oracle application user from third party application -
Hi All! I am using OC4J as a J2EE container with an Oracle Applications setup (11.5.10, LINUX version). This is for an application which gets called from Oracle Applications. We need the user, responsibility and session information of Oracle applicat
-
I guess I didn't register it to this account since it's not there. I'm going to check my other emails to see if maybe I registered it to a different account and I'm going to keep looking for the cd. But is there any hope of getting my programs from o
-
[BUG] af:validateLength breaks when only minimum length is specified
Hi, here's a bug I just found using JDev 11.1.1.0.2. The following validated input field: <af:inputText id="inputName" binding="#{backingBeanScope.MyBean.inputName}"> <af:validateLength minimum="8"/> </af:inputText>using only a mini
-
How do i watch movies from an external hard drive on my macbook and iPad?
how can i watch movies on my macbook and ipad from an external hard drive?
-
Windows 7 64bit on MSI GX660 stopped working.
My windows 7 64 bit on GX660 stopped working properly after a restart,and now i cant even use the recovery to repair it.It lets me start the tool and run it but when its done it just boots and goes to screen that tells me to repair the boot sector.Iv