Open futureflsl opened 8 months ago
I known Cv2.Split can complete this funtion,but some time,we have to use pointer convert to r,g,b channel,like this
Mat image = Cv2.ImRead("E:\\animal.jpg"); int out_h = image.Height; int out_w = image.Width; int channel_step = out_h * out_w; Mat rmat =new Mat(out_h, out_w, MatType.CV_32FC1, image.CvPtr); Mat gmat = new Mat(out_h, out_w, MatType.CV_32FC1, image.CvPtr+channel_step); Mat bmat = new Mat(out_h, out_w, MatType.CV_32FC1, image.CvPtr+2 * channel_step); rmat *= 255f; gmat *= 255f; bmat *= 255f; Cv2.ImShow("R",rmat); Cv2.ImShow("G", gmat); Cv2.ImShow("B", bmat); Cv2.WaitKey(0); Cv2.DestroyAllWindows();
but the code can not run well,how modify it to work normally?
You should first consider using Cv2.Split(), but you may find the following page helpful for other methods: https://stackoverflow.com/questions/21619609/split-channels-from-rgb-array-in-c-without-opencv
I known Cv2.Split can complete this funtion,but some time,we have to use pointer convert to r,g,b channel,like this
but the code can not run well,how modify it to work normally?