Image Processing on Java - java

I'm working on a college project, where I need to handle images in java. Sometime ago I worked in math lab and it was so easy, so I would like to know if exits any java library that could let me play with the pixels values, color(by pixel), RGB model, gray-scale img, etc.

I don't know matlab, but I worked with Java image processing a lot... Java standard library provides tons of methods to work with images on low level. You can access image pixels through BufferedImage. Make sure to read and understand the classes BufferedImageOp, RasterOp and ConvolveOp otherwise you may end up reinventing stuff.
The best examples for java image processing are on http://www.jhlabs.com/ There you can also find open source image editor and the source code for all the image effect demos.

Look at BufferedImages. You can load/save/edit images with it
http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImage.html
http://download.oracle.com/javase/tutorial/2d/images/index.html

You might want to take a look at the following classes:
java.awt.image.BufferedImage
java.awt.image.Raster
javax.imageio.ImageIO
Depending on the image formats you might also have to look (I hope not) at JAI and JAI-imageio.

Well, there is a library available in Java which can help to access Matlab code with in Java program. Please check http://code.google.com/p/matlabcontrol/

I tend to use DataBuffer objects for this kind of stuff. It's not very fast, but if you want to get out pixel information easily, it's the easiest way to do it. It's stored in the Raster of the BufferedImage.

Related

Is it possible to determine the type of png compression on Android bitmaps?

I know there are different types of png compression formats (using color palette for example). Is it possible to (programatically) determine the type I want to use when compressing a Bitmap in Android?
If the answer is no, can anyone suggest a method for doing so?
Thanks
In Android there's no client API to specify that, because Bitmap.compress() calls a native method which doesn't accept such a parameter.
However you can use libpng (which BTW is what I think Android uses in its native implementation) and it certainly allows the fine-grained control you need.
But I really don't think that saving a bunch of KBytes in a GB-sized drive is worth this effort.
You can also use PNGJ, it allows full control over the writing parameters.
Eventually I had to make changes to the Android's skia library, since I didn't want to add any Java code (I need to make png compressions fast).
If anyone needs such a solution,
I uploaded mine to:
https://github.com/androidcompile/Android_external_skia_pngCompression

video Image processing , how can i?

So Here is the situation.
I have a video that contain some objects that moves (contract to be more accurate),
I'm trying to write a code to calculate these movements in matter of
Frequency of movements (how many contractions per minute)
How far does the contraction goes in mm.
How can this be done ?? :D!
I use Matlab now to to blot amplitude difference between each frame but its not giving very nice results so far.. (very buggy)
Any tips ? language i should use best, or is there already something exist that can compare different images and plot difference ?
Thanks
You should try Processing using one of these libraries.
Keywords to search for: Blob detection, Computer Vision
The best library for tracking moving objects is OpenCV, which can be used from within Processing, too. Tracking faces for example works like a charm there, but for more abstract shapes you should try another library like BlobDetection!
OpenCV is a great library if you plan to write into C/C++ (or wrapped into JavaCV if you prefer Java). Matlab is a great tool too, especially if you are working on a proof of concept you may want to work with something more friendly and "lighthearted" than C.
If you plan to measure positions or distances I suggest you to use some calibration toolbox to consider intrinsic/extrinsic parameters and eventually camera defects, it will give you more precise results. It is builtin into OpenCV, or take a look here if you plan to use Matlab.
so i'm not expert on this but if you want write something in php you probably would use gd library or imagemagick library also imagemagick utility on linux contains some comparing tool according this http://www.imagemagick.org/script/compare.php

Image manipulation

I am just wondering what kind of computing/programming language/frameworks are needed to produce images such as the one in http://www.erdas.com/ ?
Programmatically, how does one produce the general spatial analysis images ?
ps: I use java most of the time.
Thanks
First of all, uDIG, OpenJUMP (not sure about this) cannot process images in a way that ERDAS can. These softwares are great, but they do not have extensive raster funcionality.
You need to take a look at GDAL, which covers a bunch of languages and can manipulate imagery.
http://www.gdal.org/
As we speak the PostGIS team is building most of PostGIS WKT Raster funcionality on top of GDAL. It is a fantastic tool and consolidated library.
I'm not sure which image do you mean, but geospatial images can be manipulated by software called GIS. Examples in Java are:
OpenJUMP
uDig
and a spatial manipulation library:
GeoTools
You need to obtain the imagery from a provider and then you analyze it with various tools. For raster you could also look at sextante as a raster analysis library written in Java.
The tools mentioned above are the two best Java Desktop options unless you speak spanish and then I would reccomend gvSIG.

Getting an image from a game model

So I'm not 100% sure if it's possible, but what I'd like to do is take a model that someone has created for a game, say in Blender or something similar, in various formats, and from that create an image to show on a website.
Are there any Java libraries around that could help me with that? Java3D maybe? Or even something in Flash? Ideally you'd be able to rotate the model in some embedded flash app, but I'd settle for a plain old image.
It depends on how far you want to go. Most models are going to be in a standard format- or can easily be converted to be - and most 3D Apis are able to load these formats in.
It would be a little unusual to do this on a server - you may even need to have OpenGL installed on it - but it should be quite easy to load a model in to a 3D environment and take a snapshot or a series of snapshots quite easily. Possibly even use these to create a short video clip of a complete turn around the model. If you're using Java take a look at some of the things people are working on over at http://www.javagaming.org/ - I don't know that Java3D is in use much still but there are other good 3D java environments around. JMonkeyEngine looked most interesting last time I was exploring that area.
Alternatively you probably can set up a way of loading the model into a clientside environment - I don't know if Flash can do 3D stuff now, but Shockwave certainly can ( although it's horrible to work with ) and I believe the Silverlight stuff likewise. Of course unless you are pregenerating your animations you are likely to be passing the model to your display logic on the client and a savvy user could intercept that, but the risk is probably reasonably low and from your question it's not clear whether that would be a problem to you.
Take a look into this post:
http://techblog.floorplanner.com/2010/01/25/introducing-asblender/
"Enter ASBlender, a library I slapped together in a few days to read Blender’s .blend file format and parse it to AS3."
lucky you! ;)
EDIT: added link for the project:
http://github.com/timknip/asblender
EDIT2: With the asblender library you can parse directly the .blend file (this is the working file, not a exported file format). Once you have the file inside the flash application you can use Papervision (I believe you do the same with other 3d libraries) to render the model, this way you can do a single image of the model or you can let user to see the model rotating. Beware that any of this libraries won't give the same render quality that a 3D application like blender is capable of. The good thing about this library is the capability of reading all the info in the scene, so you can match cameras and lights to be as close as possible to the original .blend file.
Alternatively there are also other parsers like Ase, Collada , DAE, KMZ, Max3DS, MD2, Sketchup, SketchupCollada... all of this inside papervision library.

Can I convert a .swf file to an image format?

I need to take a .swf Flash file, ideally from a URL (but I can read the file from disk also) and create an image preview of it (png, gif or jpeg is fine).
I am using Adobe Coldfusion 8 so I'm looking for a Java solution. I need to get the first frame of the Flash movie only.
Many thanks in advance.
EDIT: I need to do this on the server in Java/CF at runtime - it's got to be automatic - I'm not looking for screen-grab software! :)
Is this running in a web browser? Or standalone - actually, either works. Simply get it to the point you want, and take a screenshot (Print Screen). That'll giev you an image you can paste into your image app of choice.
IF however you're wanting to code it, you'll need to probably want to try this freeware toolkit:
http://bytescout.com/swftoimage_swf_to_jpg.html
which allows you to take a flash file and convert the first frame to your image type of choice :)
Try swftools. It has utility called swfrender which can export frames into images. And it is open source :).
I'm not an expert but I think you can't without some tricky tools because SWF is a compiled flash program.
UPD: but there are some swf2flv converters, maybe u can use them. It is easier to make a preview from flv format.
UPD 2: I see several answers that recommends you to open it in a browser and make a print screen. If you really want to do this, look at JxBrowser.
AS3 has the capability to store the pixels that represent the entire screen into a BitmapData object, pass that to a JPG/PNG encoder, and post it to the server. There is a document on Adobe's devnet here that explains how the ActionScript works and what is needed with regard to PHP, shouldn't be hard to translate to CF.
here's an .net article:
http://www.codegod.de/WebAppCodeGod/screenshot-of-webpage-with-aspnet-AID398.aspx
basically you create a webpage showing the .swf flash file.
remember to call iecapt.exe including the command line argument --delay=10000 to give the ie activex control 10sec to load the .swf
Probably not what you're looking for but... Alt+Print Screen would work.. :)
More seriously.. find something that can render flash (IE ActiveX control?) and capture the buffer it renders.

Categories

Resources