ColorHistogram from Mat

109 views
Skip to first unread message

hanoun

unread,
Apr 21, 2012, 8:18:53 AM4/21/12
to android...@googlegroups.com
Hello, 
Can someone tell me how i generate color histogramm from Mat image?
I try with this
ArrayList<Mat> images = new ArrayList<Mat>();
        List<Integer> channels = new ArrayList<Integer>();
        List<Integer> histSize = new ArrayList<Integer>();
        List<Float> ranges = new ArrayList<Float>();           
                       
            images.add(img);
            channels.add(0);
        histSize.add(10);
        ranges.add(0.0f); ranges.add(256.0f);
        Mat hist = new Mat();      
        Imgproc.calcHist(images, channels, new Mat(), hist, histSize, ranges);
But it dosn't work
       
         
         

peppschmier

unread,
Apr 23, 2012, 4:41:25 AM4/23/12
to android...@googlegroups.com
Do you get any Error-Messages in your LogCat Output window?

hanoun

unread,
Apr 23, 2012, 9:13:08 AM4/23/12
to android...@googlegroups.com

No

hanoun

unread,
Apr 23, 2012, 9:24:45 AM4/23/12
to android...@googlegroups.com

       My problem is comparing two image i procced by local image the method of compareHist give exact results, but when get byte from database or from url and convert to bitmap and then to Mat 
    it gives me wrong results, Can you help me please?        

peppschmier

unread,
Apr 25, 2012, 2:34:57 AM4/25/12
to android...@googlegroups.com
Looks like you're facing a problem at the conversion. If your code works with local images (do you read them with imread()?) it should work for other images too. Maybe your conversion from byte --> bitmap --> mat isn't correct? You could do some debugging if you write out your images from databases or urls after loading them into a Mat with imwrite(). Then you can check if you have correct input data. 

Kirill Kornyakov

unread,
May 4, 2012, 4:17:49 AM5/4/12
to android...@googlegroups.com
You can check updated image-manipulations sample in OpenCV 2.4 package.
Reply all
Reply to author
Forward
0 new messages