Loading an image in Java without AWT - java

I am on an embedded platform without access to AWT. I was wondering if anyone knew of a standalone library to load images without any AWT involvement.
Thanks,
Braden McDorman

Perhaps AWT headless mode can help?
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/

I took the semi-easy way out and created a tool to convert images to RGB565 raw files. Then I have a custom loader.

Have a look at JIMI.
http://java.sun.com/products/jimi/
Easy to work with, bought by Sun, superceeded by JAI which is not as easy to work with.
(And now the page is Oracle-branded...)

Not a standalone library and not sure what your platform offers, but you can try the javax.imageio.ImageIO (Java SE 1.4 and later).
Just use one of the read methods to get a BufferedImage.

Related

Is there a java library for image?

I am new to image processing in java .
I was given a task to re-size and scale images image of a web site
Is there a simple Library that will do this task?
a library where i have to download a jar - added to my project ?
I prefer not to be forced to install codecs and files to the windows.
I need the library to support only the basic functions
Lib.cropImage();
Lib.resizImage();
Lib.scaleImage()
I already found a library called JAI but I can't find the jar to download it.
Am I missing something ?
You can use the standard Image class part of Java libraries.
Scaling images should be fairly easy by using Image.getScaledInstance(int width, int height, int hints)
For cropping, use BufferedImage.getSubimage() (see this StackOverflow Q&A for more details). For resizing, use Graphics.drawImage() (see this StackOverflow answer for more details). And for scaling, use Image.getScaledInstance().
Other options are:
JMagick (see this StackOverflow answer).
ImageJ
Use ProcessBuilder to execute ImageMagick commands.
The Java2D library ought to be sufficient enough.
For image processing puroses I would recommend a package from the following list.
In your case JAI would do the job, and you can download it here.
Have you tried imageJ which boasts to be world's fastest pure Java image processing program

Image Processing on 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.

turn a web page into an image with ColdFusion, Java or command line utility?

Native ancient solution in ColdFusion that used to work with HTML 3.x...
<cfhttp url="#targetUrl#" resolveurl="yes">
<cfdocument format="pdf" name="pdfVar">
#cfhttp.filecontent#
</cfdocument>
<cfpdf action="thumbnail" source="#pdfVar#" pages="1" destination="image">
<cfimage action="writeToBrowser" source="#image#">
Super slow, even with cache, many CSS styles missing or broken.
Any good server-side solution to capture a rendered webpage into a thumbnail? like service provided by http://www.shrinktheweb.com/ ?
Any ColdFusion, Java or Command line utility solution?
This website has a script that does what I think your looking for, I haven’t tried using it for any server-side project though.
http://khtml2png.sourceforge.net/
Doesn’t make thumbnails though, but you could render the image created with cfimage.
If you have ColdFusion version 8 or better, you can simply use CFDOCUMENT to create a thumbnail.
From Ray's post:
<cfdocument src="http://www.coldfusionjedi.com" name="pdfdata" format="pdf" />
<cfpdf source="pdfdata" pages="1" action="thumbnail" destination="." format="jpg" overwrite="true" resolution="high" scale="25">
We ended up using SiteShoter which uses IE as the renderering engine. http://www.nirsoft.net/utils/web_site_screenshot.html

Image Processing via Standalone application

I'm developing a project for doing Content Based Image Retrieval where front end will be in java.
The main issue is about choosing tool for performing image processing. Since Matlab provides a lot of functionality for doing CBIR. But the main problem about using Matlab is that you need to have Matlab installed on every computer using the application.
Is there any other way in which I can do my project (Using other tools or driver) so that my application will run without using any other tools ???
Or can I develop entire application in Matlab only and deploy it as a standalone application ???
Thank you..
There are plenty of image processing libraries, for example for Java: ImageJ, there is also one by the Apache Commons project. If you need higher-level computer vision libraries there is OpenCV for C++ that also has bindings for Java, for example.
You can also develop the entire application in Matlab, but to deploy a stand alone application requires this requires licensing Mathworks Builder NE (which can be expensive). Matlab is very good for research and prototyping purposes.
There are other alternatives that are amenable to quick prototyping for example Python and PIL.
I think the bottom line is that there are plenty of options.
Java image utilities library: A Java library for loading, editing, analyzing and saving pixel image files.
It supports various file formats.
Provides demo applications for the command line. It has AWT GUI toolkit too.
Matlab is an excellent tool for prototyping as already pointed out by carlosdc. Matlab offers limited options with regard to UI programming. GUIDE is ok for small projects, but hinders more than it helps on bigger ones.
With MATLAB Builder JA you're able to compile your Matlab code into Java classes.
With regard to plotting time series in real time, libraries like JFreeChart are way slower.
I think OpenCV is one of the best libraries out there for image processing but Java Advanced Imaging is also quite good but doesn't has as much features and examples. Color similarity would be simple in JAI but shape probably would involve more code.
If you choose to use OpenCV I think you have at least two possible binding implementations for Java. The one my group uses is this one. It has some Processing dependencies.
Regardless of what library you choose be prepared for some frustration. Matlab users are used to all the nice features it provides and when they have to port their code to other languages end having to write a lot more code.
Well, after a long search finally I've found the way to deploy Matlab code along with java that too standalone application..
The steps are simple::--
1. Go and get Javabuilder.jar file located at location::
Matlab\toolbox\javabuilder\jar\javabuilder.jar
Next type deploytool in Matlabs command line...
deploytool window will open now create a new java project.
Select Matlab files that you want to use.
The deploytool will now convert the .m file to .jar file.
Now use both of the above mentioned jar files and develop your java compatible matlab code
and thats the way you can create the standalone application of matlab..

Does Java work with PCF fonts?

I am trying to make IBM jre to use PCF fonts from default X11 installation on my linux box. In particular adobe-helvetica font. I have toyed to modify fontconfig.properties in jre/lib folder but no matter what I do Java seams to use some other fonts. I guess there is some algorithm how java VM tries to link java logical fonts to actual physical fonts in the system even in case when font specified in config could not be used. On Windows it is pretty straight forward, but on Linux I was unable to make it work with anything except TrueType fonts.
Anybody have experience with configuring fonts on IBM jre on Linux?
I've spent all morning learning about Java fonts. There's a lot of limitations, some of which are removed in Java 1.6. I don't have any answers, but here is some information I have that might be helpful.
Java distinguishes internally between system fonts and created fonts. (News flash to Sun: it'd be nice to make that clear through subclassing!) The system fonts seem to be fonts installed in the JRE possibly plus some of the fonts installed on your system. But apparently not all of the fonts installed on your system; I, too, have adobe-helvetica on my Linux system but it doesn't seem to be accessible from Java under any name I can think of.
Meanwhile, you can create fonts from a font file with the Font.createFont() method. You have to specify the font file type. The only constants I found to specify these types in the Font class are TRUETYPE_FONT and TYPE1_FONT. So it looks like if PCF fonts are available, it isn't made explicit through providing a constant to specify them. Maybe somebody else knows more. I did see some information online about using bitmap fonts in Java ME, so it must somehow be possible to use other types of fonts.
Once you have a created font, you can add it to the JVM's concept of available fonts with the GraphicsEnvironment.registerFont() call, but that is only available on Java 1.6 and later.
The PCFFont package seems to provide the ability to use PCF fonts from Java. Unfortunately I think it does so with a custom PCFFont class which does not extend the java.awt.Font class, so I would say its usefulness is probably limited. However, it might give some pointers to implementation details for writing a custom subclass of Font which can handle PCF fonts. Finding the source code isn't immediately obvious; code for that exact class is here.
I would say the author seems a little confused, because he talks about converting TrueType fonts to PCF so you can use them with his library, and Java already supports TrueType fonts natively. But he appears to be an engineer from Sun, so maybe he knew more than I think; also, this could just be very out of date (was there ever a time when Java didn't support TrueType?).

Categories

Resources