I have used Java language for beginners is used with object type calling so there's an app or software called processing that I used that's a bit easy at making programs... (https://processing.org/)
What could be the best shortest example to make a animated GIF using shapes/ images?
What way could be the best way to make a GIF animated in regular Java without using processing software?
What could be the easiest examples for a beginner to do an animated GIF?
Stack Overflow isn't really designed for general "how do I do this" type questions. It's for specific "I tried X, expected Y, but got Z instead" type questions. But I'll try to help in a general sense:
You need to break your problem down into smaller steps and then take those steps on one at a time. Can you create a simple animation? Something simple like a circle moving around the screen. Separately from that, can you export a single .png image from a sketch? Again, just something simple. Work your way forward in small steps: can you then export each frame of a simple animation as a .png file?
Then when you have those .png files, you can use something like Image Magick to convert them into an animated gif file.
The Processing reference is your best friend for questions like this. The save() and saveFrame() functions could come in handy for exporting an animation as a gif.
Please try something, and if you get stuck, post a MCVE along with a more specific technical question in a new post. Good luck.
My aim is to let the user take a selfie from my app and then apply different image processing algorithms to convert it in a cartoon type image. I followed the algo written here, and then also used the method written just below the chosen answer to convert black and white sketch to colored image that should look like cartoon. Every thing is ok except that after applying Gaussian Blur , the image becomes too hazy and unclear. Here is the image output:
Any advice how I can make it more clear? Like shown in this link. I know they used Photoshop , but I want to achieve it with Java and Android.
PS: I found all the image processing methods from here. Plus the method mentioned here (the one below the chosen answer), what could be the ideal values in the arguments?
cartoonifying image
If you have a basic knowledge of C++, you can port this app for your need.
This application works real time. If you want to non-real time,than you can use bilateral filter against two medianBlurs at the bottom of function. That will give better results, but bad performance. But you need to use OpenCV in your application. If you want to make application with more functions, I will suggest you to do it.
I'm doing a project to implement virtual chemistry laboratory system. I tried to do this by using java2D. I have come across a big issue here. that is how to show some kind of filling effect to a beaker or to a flask (beaker is an image). I tried out this with setPixel() method in WritableRaster(java.awt.image) class. but it is not much useful.
I need a help to show something filling to a beaker and to show color change when mixing two chemicals. please remember that beaker is an image. thanks in advance if anyone can give me a solution with sample code.
Conveniently, many classes implement the Shape interface. Implementing classes work well with fill(), as shown here. To display color transitions, consider AlphaComposite, shown here.
I'd advise using a dynamic SVG canvas using Batik, and then you can use advanced high-level features like masks and blending and such. It's not the most efficient solution, but who cares? It's flexible for the future. Also, it'd take a lot of optimisation to work out what parts of the image have actually changed and pass that through for efficiency. I expect Batik does that as standard. Also, you'll have something that looks really very nice.
Anyway, then you just need to use Inkscape to create the SVG, and then modify the DOM (Document Object Model) accordingly. It's just like messing with HTML. Here is some SVG beaker clipart.
just wondering if there is a simple way in java to display the contents of say 16x16 array of doubles [0..1] as a greyscale image (ala matlab)? using an unfamiliar matrix library, so I'd like to check that I'm on the right track. don't really care if it is slow or ugly, or if it requires external library - it's just there for a quick look, so as long as it works, I'm fine.
Take a look at java.awt.MemoryImageSource.
The javadoc gives an example of how to use this class similar to what you need.
The Component.createImage(ImageProducer) method can then convert this into an Image that you can display in swing components with an ImageIcon.
I would like to export the image in my JPanel to a vector graphics file so it can be edited and printed at a higher-than-screen resolution. Essentially I want its paint() function to be called with a destination Graphics that saves the drawing commands into a vector graphic file.
What is a good, simple way to do this? What libraries are recommended? Which vector format would be best, and why?
Have a look at The Java EPS Graphics2D package.
Many Java programs use Graphics2D to draw stuff on the screen, and while it is easy to save the output as a png or jpeg file, it is a little harder to export it as an EPS for including in a document or paper.
This package makes the whole process extremely easy, because you can use the EpsGraphics2D object as if it's a Graphics2D object. The only difference is that all of the implemented methods create EPS output, which means the diagrams you draw can be resized without leading to any of the jagged edges you may see when resizing pixel-based images, such as JEPG and PNG files.
Apache Batik will let you paint to a specialised implementation of a Graphics2D object and then export as an scalable vector graphics (.svg) file. You can then view/process/print it using an SVG-enabled browser (Firefox will handle it nativly, ISTR, IE and others can use plugins).
See the SVGGraphics2D object (process documented here)
The Java EPS mentioned by Pierre looks good, but if it isn't you might also like to look at FreeHEP Vector Graphics. Written to allow Java reuse in the High Energy Physics field it includes a vector graphics package, done through an implementation of Graphics2D. We've used it to export EPS very successfull for a number of years.
I can recommend the VectorGraphics2D library (LGPL). Although it does not support all the features of Graphics2D, I used it successfully for my project. It provides implementations of java.awt.Graphics2D for various vector file formats. It simply exports all paint operations to EPS, SVG, or PDF files.
Additional libraries for people with the same requirement:
for SVG, JFreeSVG at http://www.jfree.org/jfreesvg/
for PDF, OrsonPDF at http://object-refinery.com/orsonpdf/index.html
Both of these GPLv3 and well tested via extensive usage in JFreeChart and Orson Charts.
FreeHEP seems to work quite well although it does not appear to be maintained anymore and its bug and forum pages are gone. With just a handful of lines you get a popup dialog that can save any component to a variety of scalable and regular image formats. We have some challenging images, using alpha channel, rotated text, areas bounded by curves, and they saved perfectly, much better with with VectorGraphics2D.
The only problem I've seen so far is in jpeg save, which comes out black for all my images. This isn't very important for us given that png works, plus all the vector modes, but I'm sure it would be an issue for some.
I had to add exactly this much code to save in all these modes:
public static void showImage(Component comp)
{
try
{
ExportDialog export = new ExportDialog();
export.showExportDialog( null, "Export view as ...", comp, "export" );
System.err.println("Image save complete");
}
catch(Exception e)
{
e.printStackTrace();
}
}
There are a bunch of library jars that must be added as well.
this is basically not possible directly, as the low level java api works in terms of raster (pixels) and is never stored in vector format.
(Check the API of java.awt.Graphics to see what I mean).
there are some general purpose program that convert raster to vector formats, this is one I found on a quick search:
http://autotrace.sourceforge.net/index.html
so, using such a program you can divide your problem into two smaller problems:
convert your JPanel into a bitmap or file (http://www.jguru.com/faq/view.jsp?EID=242020)
run autotrace on the file.