-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
Summary of your issue
Inrange method is useless for the image that use DrawImage method
Environment
win10+vs2017+opencvsharp4.0.0
Example code:
paste your core code
`
using OpenCvSharp;
using OpenCvSharp.Extensions;
using static OpenCvSharp.Cv2;
using System.Drawing;
namespace RcoloR
{
class Program
{
static Bitmap Mybmp = new Bitmap("E:/CVIMG/lenna.png");
static void Main(string[] args)
{
using (new Window("SRC", WindowMode.Normal, Mybmp.ToMat())) ; //source image
Prtsc(Mybmp, out Bitmap dst); //crop image
using (new Window("IMAGE_CUT", WindowMode.Normal, dst.ToMat())) ; //show the cropped image
MyInrange(dst,out Bitmap dstbmp); // Inrange
using (new Window("DST", WindowMode.Normal, dstbmp.ToMat())); //show the inranged image
WaitKey();
}
static void Prtsc(Bitmap src, out Bitmap dst) // crop image
{
dst = new Bitmap(300,300);
using (Graphics g = Graphics.FromImage(dst))
{
g.DrawImage(src,new Rectangle(0,0,300,300),new Rectangle(0,0,300,300),GraphicsUnit.Pixel);
}
}
static void MyInrange(Bitmap bmpsrc,out Bitmap dstbmp) // Cv2.Inrange();
{
using (Mat src = BitmapConverter.ToMat(bmpsrc))
using (Mat dst = new Mat())
{
Scalar low_value = new Scalar(100, 100, 100);
Scalar high_value = new Scalar(255, 255, 255);
InRange(src, low_value, high_value, dst);
dstbmp = dst.ToBitmap();
}
}
}
}
`
## Output:
paste your output
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested

