main
pinb 6 months ago
parent ac9307dfce
commit 09e8a6ed5a

@ -53,7 +53,7 @@
</div>
<br />
<div>
<h3 id="-parameters-"><strong>Gabor Filter 실행 (속도 느림 주의)</strong></h3>
<h3 id="-parameters-"><strong>Gabor Filter 실행</strong></h3>
@if (srcGabor != null)
{
<img src="data:image/bmp;base64,@Convert.ToBase64String(srcGabor.ToBytes())" />
@ -146,7 +146,7 @@
}
private List<Option> options = new List<Option>
{
new Option { Value = "0", Text = "Lenna" },
new Option { Value = "0", Text = "lenna" },
new Option { Value = "1", Text = "Mandrill" },
};
private int valthreshold = 127;
@ -182,9 +182,12 @@
try
{
Mat gabor_filter = Cv2.GetGaborKernel(new Size(kernel_size, kernel_size), sigma, theta, lambd, gamma, psi, MatType.CV_32F);
Mat kenel = new Mat(5, 5, MatType.CV_8UC1);
if (rstGabor != null)
{
rstGabor.Release();
}
rstGabor = new Mat();
Cv2.Filter2D(grayMat, rstGabor, grayMat.Type(), kenel);
Cv2.Filter2D(grayMat, rstGabor, grayMat.Type(), gabor_filter);
}
catch (Exception ex)
{
@ -196,7 +199,10 @@
{
if (srcBinary is null)
throw new InvalidOperationException($"{nameof(srcBinary)} is null");
if (rstBinary != null)
{
rstBinary.Release();
}
rstBinary = new Mat(srcBinary.Size(), MatType.CV_8UC1);
Cv2.CvtColor(srcBinary, rstBinary, ColorConversionCodes.BGR2GRAY);
}
@ -207,6 +213,10 @@
throw new InvalidOperationException($"{nameof(srcBinary)} is null");
using var grayMat = new Mat();
if (rstBinary != null)
{
rstBinary.Release();
}
rstBinary = new Mat();
Cv2.CvtColor(srcBinary, grayMat, ColorConversionCodes.BGR2GRAY);
Cv2.ApplyColorMap(grayMat, rstBinary, ColormapTypes.Jet);
@ -218,6 +228,10 @@
throw new InvalidOperationException($"{nameof(srcBinary)} is null");
using var grayMat = new Mat();
if (rstBinary != null)
{
rstBinary.Release();
}
rstBinary = new Mat(srcBinary.Size(), MatType.CV_8UC1);
Cv2.CvtColor(srcBinary, grayMat, ColorConversionCodes.BGR2GRAY);
Cv2.Threshold(grayMat, rstBinary, valthreshold, 255, ThresholdTypes.Binary);
@ -225,8 +239,18 @@
private void SelectImage(string name)
{
string imagePath = $"wwwroot/images/{name}.bmp";
srcBinary = Cv2.ImRead(imagePath);
Cv2.Resize(srcBinary, srcBinary, new Size(width, height));
try
{
string imagePath = $"wwwroot/images/{name}.bmp";
if (srcBinary != null)
{
srcBinary.Release();
}
srcBinary = Cv2.ImRead(imagePath);
Cv2.Resize(srcBinary, srcBinary, new Size(width, height));
}
catch(Exception e)
{
}
}
}
Loading…
Cancel
Save