opencvsharp 直方图显示笔记

            Mat[] mats = new Mat[] { src_img  };
            Mat hist = new Mat();
            int[] channels = new int[] { 0 };
            int[] histsize = new int[] { 256 };
            Rangef[] range = new Rangef[1];
            range[0].Start =  0.0f;
            range[0].End = 256.0f;
            Mat mask = new Mat();
            Cv2.CalcHist(mats, channels, mask, hist, 1, histsize, range);
            
            for (int i = 0; i < 256; i++)//画直方图
            {
                    int len = (int)((hist.Get(i) / 10000) * src_img.Rows);
                    Cv2.Line(src_img, i, 0, i, len, color[0], 2);
            }
            Cv2.ImShow("ceshi", src_img);

 

你可能感兴趣的:(opencv的小日记)