resize, slice

remotes/origin/master
syneffort 3 years ago
parent 77db30ee31
commit 8bf98d3076
  1. 1
      OpenCV/Form1.Designer.cs
  2. 4
      OpenCV/Form1.cs
  3. 34
      OpenCV/OpenCVClass.cs

@ -40,6 +40,7 @@ namespace OpenCV
this.pictureBoxIpl1.Location = new System.Drawing.Point(12, 12); this.pictureBoxIpl1.Location = new System.Drawing.Point(12, 12);
this.pictureBoxIpl1.Name = "pictureBoxIpl1"; this.pictureBoxIpl1.Name = "pictureBoxIpl1";
this.pictureBoxIpl1.Size = new System.Drawing.Size(640, 480); this.pictureBoxIpl1.Size = new System.Drawing.Size(640, 480);
this.pictureBoxIpl1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBoxIpl1.TabIndex = 0; this.pictureBoxIpl1.TabIndex = 0;
this.pictureBoxIpl1.TabStop = false; this.pictureBoxIpl1.TabStop = false;
// //

@ -39,8 +39,8 @@ namespace OpenCV
OpenCVClass Converter = new OpenCVClass(); OpenCVClass Converter = new OpenCVClass();
pictureBoxIpl1.ImageIpl = src; pictureBoxIpl1.ImageIpl = src;
//pictureBoxIpl2.ImageIpl = Converter.ZoomIn(src); //pictureBoxIpl2.ImageIpl = Converter.Resize(src, 0.1, 0.2);
pictureBoxIpl2.ImageIpl = Converter.ZoomOut(src); pictureBoxIpl2.ImageIpl = Converter.Slice(src, 750, 840, 350, 150);
} }
catch (Exception ex) catch (Exception ex)
{ {

@ -11,6 +11,8 @@ namespace OpenCV
IplImage blur; IplImage blur;
IplImage zoomin; IplImage zoomin;
IplImage zoomout; IplImage zoomout;
IplImage resize;
IplImage slice;
public IplImage GrayScale(IplImage src) public IplImage GrayScale(IplImage src)
{ {
@ -54,6 +56,34 @@ namespace OpenCV
return zoomout; return zoomout;
} }
public IplImage Resize(IplImage src, double widthRate, double heightRate)
{
resize = new IplImage(new CvSize((int)(src.Width * widthRate), (int)(src.Height * heightRate)), BitDepth.U8, 3);
Cv.Resize(src, resize, Interpolation.Linear);
return resize;
}
public IplImage Slice(IplImage src, int x, int y, int roiWidht, int roiHeight)
{
//slice = new IplImage(new CvSize(roiWidht, roiHeight), BitDepth.U8, 3);
//src.ROI = new CvRect(x, y, roiWidht, roiHeight);
//src.SetROI(new CvRect(x, y, roiWidht, roiHeight));
//Cv.SetImageROI(src, new CvRect(x, y, roiWidht, roiHeight));
//Cv.Copy(src, slice);
//Cv.Resize(src, slice);
//slice = src.Clone(); // 속성까지 복사되어 채널 등 값이 변경됨
//src.ResetROI();
//Cv.ResetImageROI(src);
CvRect roi = new CvRect(x, y, roiWidht, roiHeight);
slice = src.Clone(roi);
return slice;
}
public void Dispose() public void Dispose()
{ {
if (gray != null) if (gray != null)
@ -68,6 +98,10 @@ namespace OpenCV
Cv.ReleaseImage(zoomin); Cv.ReleaseImage(zoomin);
if (zoomout != null) if (zoomout != null)
Cv.ReleaseImage(zoomout); Cv.ReleaseImage(zoomout);
if (resize != null)
Cv.ReleaseImage(resize);
if (slice != null)
Cv.ReleaseImage(slice);
} }
} }
} }

Loading…
Cancel
Save