11

I am not having any idea of how to apply different effect on Image,

I have seen the EffectFactory class and Effect class in effect class there is one method apply but I am not sure what to pass in inputTexId and optputTexId, and from where I get the new updated image, how to store the updated image in imageView,

Please help me with how to approach this problem. Is there any opensource library available for providing effects on Image.

Thanks,

Kees de Vriesch
  • 124
  • 2
  • 14
Nixit Patel
  • 4,435
  • 5
  • 30
  • 57

4 Answers4

9

I have implemented Jerry's Java Image Processing Library. Works fine for me.

Download AndroidJars.

Edit

Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
//Find the bitmap's width height
int width = AndroidUtils.getBitmapOfWidth(getResources(), R.drawable.ic_launcher);
int height = AndroidUtils.getBitmapOfHeight(getResources(), R.drawable.ic_launcher);
//Create a filter object.
GaussianFilter filter = new GaussianFilter();
//set???? function to specify the various settings.
filter.setRadius(8.5f);
//Change int Array into a bitmap
int[] src = AndroidUtils.bitmapToIntArray(bitmap);
//Applies a filter.
filter.filter(src, width, height);
//Change the Bitmap int Array (Supports only ARGB_8888)
Bitmap dstBitmap = Bitmap.createBitmap(src, width, height, Config.ARGB_8888);

Find more detailed information at Android-jhlabs

Chintan Rathod
  • 25,864
  • 13
  • 83
  • 93
  • did u implement in java oriented application or android application – blackjack May 06 '13 at 08:45
  • For android my friend, not yet in java oriented application.They are doing operation upon "integer array" of "image". Bad news is that library is specifically for android. But still we can fetch out logic from java files. – Chintan Rathod May 06 '13 at 09:24
  • can you give an example how to use this lib with bitmap. – Singhak Dec 01 '13 at 10:31
  • @ChintanRathod thanx sir I will try it and if any problem then i will ask – Singhak Dec 02 '13 at 08:38
  • AndroidUtils not found using this libs and also filter.filter(src, width, height); is changed to BufferedImage filter(BufferedImage src, BufferedImage dst) . can you tell me how to implement on new library, Thanks – Rahul Mandaliya Aug 22 '15 at 05:59
  • @RahulMandaliya I need to check how to use that library with new methods. :) – Chintan Rathod Aug 22 '15 at 09:56
  • 2
    Thanks me for refering to the AndroidUtils class .. https://github.com/mordonez-me/instagram-filters-jhlabs-android/blob/master/ImageFilters/src/main/java/com/jabistudio/androidjhlabs/filter/util/AndroidUtils.java – Xar-e-ahmer Khan Aug 27 '15 at 08:15
  • any updates on how to use the BufferedImage filter? @Chintan Rathod – MetaSnarf Oct 29 '15 at 08:58
  • there is an error trying to use BufferedImageOp. I think android disallows this. – MetaSnarf Dec 07 '15 at 07:06
  • @MetaSnarf I need to check my friend. I haven't use this for long time. Might be you are right because in between 2-3 new versions of android introduced. – Chintan Rathod Dec 07 '15 at 08:35
6

You can use Catalano Framework:

http://code.google.com/p/catalano-framework/

FastBitmap image = new FastBitmap(bitmap);
image.toRGB();

//Sepia
Sepia sepia = new Sepia();
sepia.applyInPlace(image);

//Blur
Blur blur = new Blur();
blur.applyInPlace(image);

//Emboss
Emboss emboss = new Emboss();
emboss.applyInPlace(image);

//Retrieve bitmap
bitmap = fb.toBitmap();
Diego Catalano
  • 689
  • 9
  • 16
  • How is the performance of your framework? I just got started testing out some image filters, and got pretty bad performance using https://code.google.com/p/android-jhlabs/ for the one filter type I tried. – Liron Oct 14 '13 at 01:31
  • Depends on the filter you are using. The GaussianFilter for example in JHLABS should be use Separable Gaussian, so is extremely faster tha GaussianBlur in Catalano Framework because use the both direction in the same point. But I tested the benchmark with Catalano Framework, AForge.NET and Accord.NET, there are some filters of Catalano Framework outperforms AForge.NET and vice versa. The version 1.2 is comming with new features for parallel processing. You just need to change Catalano.Imaging.Filters to Catalano.Imaging.Concurrent.Filters. Stay tuned ! – Diego Catalano Oct 14 '13 at 11:18
  • What's your ETA on that? – Liron Oct 14 '13 at 12:41
  • All tests have been repeated 100 times. Initial executions (before those 100 times) have been discarded to let any possible compiler/JIT optimizations quick in before the actual measurements. All tests have been made outside Visual Studio, i.e. by going to the binary folders and running the executables directly. All binaries have been compiled in Release mode, for Any CPU (meaning they were ran in 64-bits mode). Median Filter. AForge.NET: 92650 - Catalano Framework: 82336 - Catalano Framework (Concurrent): 20843 – Diego Catalano Oct 14 '13 at 13:18
  • Sorry, I mean when is the 1.2 version coming. – Liron Oct 14 '13 at 14:31
  • 1
    I intend to publish this month, xx/10/2013 (dd/mm/yyyy). – Diego Catalano Oct 14 '13 at 15:15
  • Cool. I'll check it out when I have a chance. In release mode, your old framework is performing nicely for me. In debug it's really bad, but I don't know if there's much I can do about that. – Liron Oct 31 '13 at 12:51
  • I'll code a new Gaussian Blur using separable theorem, so I can to do GB in parallel too. – Diego Catalano Oct 31 '13 at 14:13
  • Please provide the names of different types of filters class which one can use in filtering images... – Pradeep Sodhi May 15 '14 at 10:02
  • @PradeepSodhi, you can see the names in the documentation, next month, I intend to release a version for artistic filters. – Diego Catalano May 21 '14 at 12:39
  • is this framework supported for live camera effects @DiegoCatalano or is it only for bitmap – Erum Oct 13 '14 at 16:21
  • Supports live camera, but you need to process each frame. – Diego Catalano Oct 19 '14 at 16:09
  • Hi Diego, any chance to have your great library licensed using some other license than LGPL (like Apache 2.0)? I tried finding out if one could use an LGPL library in an Android project and due to lack of dynamic linking and some other wording from LGPL itself ... its not really possible / legal. Googling for "LGPL library in an android app" will show you what I refer to. – Piotr Oct 21 '14 at 13:33
  • Hello Piotr, you have reason about the dynamic linking. Several classes/methods are own making, so I can change quickly to Apache 2.0, some others doesn't, althought I need to contact the original authors for to get permission. Please, describe the classes, methods that you need to re-license to Apache 2.0, I'll check asap. :) – Diego Catalano Oct 21 '14 at 14:03
  • I use FastBitmap and few filters (Artistic.HeatMap, Emboss, FastGaussianBlur, Grayscale, Invert, Mirror, Variance, BradleyLocalThreshold, Rotate and Sepia). – Piotr Oct 21 '14 at 17:48
  • It´s OK, I just need to check the Bradley, Rotate and Sepia. The others you can use like Apache 2.0, I'll re-license these. :) – Diego Catalano Oct 21 '14 at 22:37
  • Awesome, I will rewrite Sepia using ColorMatrixColorFilter. I will drop Rotate in favor of Matrix.setRotate. Any binarize filter I could use that you can license as Apache 2.0? PS. Check you @live.com email account - I tried to reach you from two accounts already with no success, possibly ended up in SPAM folder? – Piotr Oct 22 '14 at 06:56
4

You can also try this project it handle a number of Bitmap Processing

Filters :-

  • Boost-Up Colors
  • Brightness
  • Color Depth
  • Color Filter
  • Contrast
  • Emboss
  • Flip and Rotation
  • Gamma
  • Gaussian Blur
  • Grayscale
  • Hue
  • Invert
  • Noise
  • Saturation
  • Sepia
  • Sharpen
  • Sketch
  • Tint
  • Vignette

Since it is in Java and does pixel label processing, it is not as fast as most C++ based library out there but it work great if bitmap size is not very big eg thumbnails.

Hitesh Sahu
  • 41,955
  • 17
  • 205
  • 154
2

This is an excellent Library, easy to integrate with gradle, It is Fast and efficent and saved my day:

https://github.com/wasabeef/picasso-transformations

this is an example of how it's use:

 Transformation trans1 = new ContrastFilterTransformation(getActivity(), 1.5f);
 Transformation trans2 = new BrightnessFilterTransformation(getActivity(), 0.2f);
 Picasso.with(getActivity()).load(uri)
        .transform(trans1).transform(trans2).into(imageview3);
Amin Guermazi
  • 1,632
  • 9
  • 19
Gal Rom
  • 6,221
  • 3
  • 41
  • 33