0

I am currently working with the Content Based Image Retrieval algorithm found on http://www.cise.ufl.edu/~fishwick/ac/2011/cbir_webpage/index.htm The algorithm is set to run on the JRE but I have replaced imports appropriately so that it will work on the ADT.Such as BufferedImage has been replaced with Bitmap. My problem is I keep getting a red line error on;

 ColorProcessor cp = new ColorProcessor(image);

The error reads; "The constructor ColorProcessor(Image) refers to the missing type Image". Can anyone point out to me what I am missing or not recognising. Any help will be much appreciated.

// a local version on the computer
            URL url = FeatureExtraction.class.getResource(name);
            System.out.println("url = " + url);
            Bitmap image = null;

            // ImageIO is not supported in Android SDK so use Bitmap to achieve the
                    // same thing.
                    //Bitmap img = BitmapFactory.decodeFile(name);
                    // System.out.println("image = " + img);


            try {
                //image = ImageIO.read(url);
                image = BitmapFactory.decodeFile(name);
                //image  = BitmapFactory.decodeStream(url.openConnection().getInputStream());
            } catch(IOException e) {
                System.out.println("read error: " + e.getMessage());
            }

            ColorProcessor cp = new ColorProcessor(image);

1 Answers1

0

The error is actually complaining about another piece of code, the ColorProcessor constructor, which takes an argument of type java.awt.Image (http://rsb.info.nih.gov/ij/developer/api/ij/process/ColorProcessor.html).

The complaint is that it can't find the java.awt.Image class definition, which I don't believe is available in Android (See How to add java.awt.image package in Android).

Anyhow, you can't pass your image variable to new ColorProcessor() because it is of type android.graphics.bitmap (http://developer.android.com/reference/android/graphics/Bitmap.html) ... not at all related to java.awt.Image required by ColorProcessor.

Community
  • 1
  • 1
trooper
  • 4,444
  • 5
  • 32
  • 32
  • Thought this would be the case. So essentially there is no way round it? I cannot use ColorProcessor in my application? – James W'almsley Aug 23 '14 at 08:28
  • It is unlikely that that the Bitmap can be converted to android.graphics.Image object and still be passed into ColorProcessor? – James W'almsley Aug 23 '14 at 08:32
  • That would appear to be the case. It doesn't look like its possible to use ImageJ with Android (that's really too bad).. at least not without modifying ImageJ itself. – trooper Aug 23 '14 at 08:36
  • Might give modification a go thanks. Will let you know how it goes. Have you got any idea on what alternatives I could use? I heard there was an ImageJ 2.0 but this is still at beta stage and it isn't explicitly clear if it is compatible with ADT. I would rather keep the code I have and find an alternative library or as you said attempt modifying ij itself. – James W'almsley Aug 23 '14 at 08:59
  • Good luck. :) It looks like the required modifications are extensive! I've been reading up on ImageJ 2.0 and get the impression that its been designed to avoid this kind of incompatibility. Beta or no, it might be worth a look. – trooper Aug 24 '14 at 16:10
  • Thanks again I have actually made my own Colorprocessor for ADT using the methods and fields from ij.processor.ColorProcessor. Removing what I don't need. – James W'almsley Aug 25 '14 at 19:06
  • 1
    Modifying ImageJ 1.x to function on Android is a huge project. One of the ImageJ2 project's goals is to make such a thing possible, but no one has devoted serious effort to it yet, and it would still be a substantial endeavor. Feel free to get involved in the community on the mailing lists, if you want to pursue it. http://imagej.net/Mailing_Lists – ctrueden Aug 28 '14 at 16:31