-
-
-@code {
- //private Mat? srcMat;
- //private Mat? srcMat2;
- private byte[] imageBytes_rgba = new byte[256 * 256 * 4];
- private byte[] imageBytes_rgba2 = new byte[256 * 256 * 4];
- private ElementReference srcCanvas;
- private ElementReference dstCanvas;
- private ElementReference srcCanvas2;
- private ElementReference dstCanvas2;
- private CanvasClient? srcCanvasClient;
- private CanvasClient? dstCanvasClient;
- private CanvasClient? srcCanvasClient2;
- private CanvasClient? dstCanvasClient2;
- private int valKernelSize = 3;
- private double valSigma = 0.0;
- private double valTheta = 0.0;
- private double valLambd = 0.0;
- private double valGamma = 0.0;
- private double valPsi = 0.0;
- private int valthreshold = 127;
-
- public void Dispose()
- {
- //srcMat?.Dispose();
- //srcMat2?.Dispose();
- }
-
- protected override async Task OnInitializedAsync()
- {
- await base.OnInitializedAsync();
- }
-
- protected override async Task OnAfterRenderAsync(bool firstRender)
- {
- if (!firstRender)
- return;
- await base.OnAfterRenderAsync(firstRender);
- int width = 256;
- int height = 256;
-
- var imageBytes = await httpClient.GetByteArrayAsync("/images/mandrill.bmp");
- //srcMat ??= Mat.FromImageData(imageBytes);
- //if(srcMat.Width < 256 || srcMat.Height < 256)
- //{
- // Cv2.PyrUp(srcMat, srcMat, new Size(256, 256));
- //}
- srcCanvasClient ??= new CanvasClient(jsRuntime, srcCanvas);
- dstCanvasClient ??= new CanvasClient(jsRuntime, dstCanvas);
-
- //await srcCanvasClient.DrawMatAsync(srcMat);
-
- unsafe
- {
- fixed (byte* pImageByte = imageBytes, pImageBytes_rgba = imageBytes_rgba)
- {
- var pRgb = pImageByte;
- var pRgba = pImageBytes_rgba;
-
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
- // RGB 채널 복사
- *(pRgba++) = *(pRgb++); // R
- *(pRgba++) = *(pRgb++); // G
- *(pRgba++) = *(pRgb++); // B
-
- // 알파 채널 추가
- *(pRgba++) = 255; // A
- }
- }
- }
- }
- imageBytes_rgba = FlipVertical(imageBytes_rgba, width, height);
- ConvertBgrToRgba(imageBytes_rgba);
-
- await srcCanvasClient.DrawPixelsAsync(imageBytes_rgba);
-
-
- //var imageBytes2 = await httpClient.GetByteArrayAsync("/images/lenna256.bmp");
- var imageBytes2 = await httpClient.GetByteArrayAsync("/images/gabor.bmp");
- //srcMat2 ??= Mat.FromImageData(imageBytes2);
- //if(srcMat2.Width > 256 || srcMat2.Height > 256)
- //{
- // Cv2.PyrDown(srcMat2, srcMat2, new Size(256, 256));
- //}
-
- srcCanvasClient2 ??= new CanvasClient(jsRuntime, srcCanvas2);
- dstCanvasClient2 ??= new CanvasClient(jsRuntime, dstCanvas2);
-
- //await srcCanvasClient2.DrawMatAsync(srcMat2);
-
- unsafe
- {
- fixed (byte* pImageByte = imageBytes2, pImageBytes_rgba = imageBytes_rgba2)
- {
- var pRgb = pImageByte;
- var pRgba = pImageBytes_rgba;
-
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
- // RGB 채널 복사
- *(pRgba++) = *(pRgb++); // R
- *(pRgba++) = *(pRgb++); // G
- *(pRgba++) = *(pRgb++); // B
-
- // 알파 채널 추가
- *(pRgba++) = 255; // A
- }
- }
- }
- }
- imageBytes_rgba2 = FlipVertical(imageBytes_rgba2, width, height);
- ConvertBgrToRgba(imageBytes_rgba2);
-
- //await srcCanvasClient2.DrawPixelsAsync(imageBytes2);
- await srcCanvasClient2.DrawPixelsAsync(imageBytes_rgba2);
- }
-
- private async Task Grayscale()
- {
- //if (srcMat is null)
- // throw new InvalidOperationException($"{nameof(srcMat)} is null");
- if (dstCanvasClient is null)
- throw new InvalidOperationException($"{nameof(dstCanvasClient)} is null");
-
- //using var grayMat = new Mat();
- //Cv2.CvtColor(srcMat, grayMat, ColorConversionCodes.BGR2GRAY);
-
- byte[] gray = new byte[imageBytes_rgba.Length];
- imageBytes_rgba.CopyTo(gray, 0);
-
- ConvertRgbaToGray(gray);
-
- //await dstCanvasClient.DrawMatAsync(grayMat);
- await dstCanvasClient.DrawPixelsAsync(gray);
- }
-
- private async Task PseudoColor()
- {
- //if (srcMat is null)
- // throw new InvalidOperationException($"{nameof(srcMat)} is null");
- if (dstCanvasClient is null)
- throw new InvalidOperationException($"{nameof(dstCanvasClient)} is null");
-
- Mat srcMat = new Mat(256, 256, MatType.CV_8UC4, imageBytes_rgba);
- using var grayMat = new Mat();
- using var dstMat = new Mat();
- Cv2.CvtColor(srcMat, grayMat, ColorConversionCodes.BGR2GRAY);
- //Cv2.CvtColor(srcMat, grayMat, ColorConversionCodes.BGR2GRAY);
- Cv2.ApplyColorMap(grayMat, dstMat, ColormapTypes.Jet);
-
- await dstCanvasClient.DrawMatAsync(dstMat);
- }
-
- private async Task Threshold()
- {
- //if (srcMat is null)
- // throw new InvalidOperationException($"{nameof(srcMat)} is null");
- if (dstCanvasClient is null)
- throw new InvalidOperationException($"{nameof(dstCanvasClient)} is null");
-
- //using var grayMat = new Mat();
- //using var dstMat = new Mat(srcMat.Size(), MatType.CV_8UC1);
- //Cv2.CvtColor(srcMat, grayMat, ColorConversionCodes.BGR2GRAY);
- ////Cv2.Threshold(grayMat, dstMat, 127, 255, ThresholdTypes.Binary);
- //
- //for (int i = 0; i < grayMat.Rows; i++)
- //{
- // for (int j = 0; j < grayMat.Cols; j++)
- // {
- // byte pixelValue = grayMat.At(i, j);
- // byte newValue = (Convert.ToInt32(pixelValue) > valthreshold) ? (byte)255 : (byte)0;
- // dstMat.Set(i, j, newValue);
- // }
- //}
- //
- //await dstCanvasClient.DrawMatAsync(dstMat);
-
- byte[] th = new byte[imageBytes_rgba.Length];
- imageBytes_rgba.CopyTo(th, 0);
-
- ConvertRgbaToGray(th);
- Threshold(th, valthreshold);
-
- await dstCanvasClient.DrawPixelsAsync(th);
- }
-
- private async Task GaborFilter()
- {
- //if (srcMat2 is null)
- // throw new InvalidOperationException($"{nameof(srcMat2)} is null");
- if (dstCanvasClient2 is null)
- throw new InvalidOperationException($"{nameof(dstCanvasClient2)} is null");
-
- //using var grayMat = new Mat(srcMat2.Size(), MatType.CV_32F);
- //Cv2.CvtColor(srcMat2, grayMat, ColorConversionCodes.BGR2GRAY);
- //
- int kernel_size = valKernelSize;
- double sigma = valSigma;
- double theta = valTheta * Cv2.PI / 180.0;
- double lambd = valLambd;
- double gamma = valGamma;
- double psi = valPsi * Cv2.PI / 180.0;
- //
- //
- //Mat rst = new Mat();
- //try
- //{
- // //Mat gabor_filter = Cv2.GetGaborKernel(new Size(kernel_size, kernel_size), sigma, theta, lambd, gamma, psi, ktype);
- // //Mat kenel = new Mat(5, 5, MatType.CV_8UC1);
- // //Cv2.Filter2D(grayMat, rst, grayMat.Type(), kenel);
- //
- // Mat gabor_filter = Gabor2DFilter.CreateGaborKernel(kernel_size, sigma, theta, lambd, gamma, psi);
- // rst = Gabor2DFilter.Filter2D(grayMat, gabor_filter);
- //}
- //catch (Exception e)
- //{
- // String log = e.Message;
- //}
- //await dstCanvasClient2.DrawMatAsync(rst);
-
- Mat srcMat = new Mat(256, 256, MatType.CV_8UC4, imageBytes_rgba2);
- Cv2.CvtColor(srcMat, srcMat, ColorConversionCodes.BGRA2GRAY);
- Mat gaborfilter = Gabor2DFilter.CreateGaborKernel(kernel_size, sigma, theta, lambd, gamma, psi);
- Mat rstMat = Gabor2DFilter.Filter2D(srcMat, gaborfilter);
- await dstCanvasClient2.DrawMatAsync(rstMat);
- }
-
- public class Gabor2DFilter
- {
- public static Mat CreateGaborKernel(int ksize, double sigma, double theta, double lambd, double gamma, double psi)
- {
- int center = ksize / 2;
- Mat kernel = new Mat(ksize, ksize, MatType.CV_32FC1);
- double sigmaX = sigma;
- double sigmaY = sigma / gamma;
-
- unsafe
- {
- for (int y = -center; y <= center; y++)
- {
- for (int x = -center; x <= center; x++)
- {
- double xPrime = x * Math.Cos(theta) + y * Math.Sin(theta);
- double yPrime = -x * Math.Sin(theta) + y * Math.Cos(theta);
- double value = Math.Exp(-0.5 * (xPrime * xPrime / (sigmaX * sigmaX) + yPrime * yPrime / (sigmaY * sigmaY)));
- value *= Math.Cos(2 * Math.PI * xPrime / lambd + psi);
-
- float* kernelPtr = (float*)(kernel.DataPointer + (center + y) * kernel.Step() + (center + x) * sizeof(float));
- *kernelPtr = Convert.ToSingle(value);
- }
- }
- }
- return kernel;
- }
-
- public static Mat Filter2D(Mat src, Mat kernel)
- {
- int kernelRows = kernel.Rows;
- int kernelCols = kernel.Cols;
- int kernelCenterX = kernelCols / 2;
- int kernelCenterY = kernelRows / 2;
- MatType type = src.Type();
- Mat dst = new Mat(src.Size(), type);
-
- try
- {
- unsafe
- {
- double* kernelData = (double*)kernel.DataPointer;
-
- for (int y = 0; y < src.Rows; y++)
- {
- for (int x = 0; x < src.Cols; x++)
- {
- double sum = 0.0;
-
- for (int kRow = 0; kRow < kernelRows; kRow++)
- {
- int yy = y + kRow - kernelCenterY;
- for (int kCol = 0; kCol < kernelCols; kCol++)
- {
- int xx = x + kCol - kernelCenterX;
-
- if (xx >= 0 && xx < src.Cols && yy >= 0 && yy < src.Rows)
- {
- byte* pixelValue = src.DataPointer + yy * src.Step() + xx * src.ElemSize();
- double kernelValue = *(kernelData + kRow * kernelCols + kCol);
- sum += Convert.ToDouble(*pixelValue) * kernelValue;
- }
- }
- }
-
- byte* resultValue = dst.DataPointer + y * dst.Step() + x * dst.ElemSize();
- *resultValue = (byte)Math.Clamp(sum, 0, 255);
- }
- }
- }
-
- }
- catch (Exception ex)
- {
- String log = ex.Message;
- }
-
- return dst;
- }
-
- }
-
- public byte[] FlipVertical(byte[] pixels, int width, int height)
- {
- byte[] flippedPixels = new byte[pixels.Length];
- int rowBytes = width * 4; // 각 행의 바이트 수 (RGBA 채널)
-
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < rowBytes; x++)
- {
- flippedPixels[(height - 1 - y) * rowBytes + x] = pixels[y * rowBytes + x];
- }
- }
-
- return flippedPixels;
- }
-
- public void ConvertBgrToRgba(byte[] pixels)
- {
- for (int i = 0; i < pixels.Length; i += 4)
- {
- byte temp = pixels[i]; // B 채널
- pixels[i] = pixels[i + 2]; // R 채널
- pixels[i + 2] = temp;
- }
- }
-
- public void ConvertRgbaToGray(byte[] pixels)
- {
- for (int i = 0; i < pixels.Length; i += 4)
- {
- byte r = pixels[i];
- byte g = pixels[i + 1];
- byte b = pixels[i + 2];
- // byte a = pixels[i + 3]; // 알파 채널은 사용하지 않음
-
- // 그레이스케일 값 계산
- byte grayValue = (byte)((r * 0.299) + (g * 0.587) + (b * 0.114));
- pixels[i] = grayValue;
- pixels[i + 1] = grayValue;
- pixels[i + 2] = grayValue;
- }
- }
-
- public void Threshold(byte[] pixels, int threshold)
- {
- for (int i = 0; i < pixels.Length; i += 4)
- {
- byte r = pixels[i];
- byte g = pixels[i + 1];
- byte b = pixels[i + 2];
-
- if(r != g || r!= b)
- {
- return;
- }
-
- pixels[i] = pixels[i + 1] = pixels[i + 2] = Convert.ToInt32(r) > threshold ? Convert.ToByte(255) : Convert.ToByte(0);
- }
- }
-}
\ No newline at end of file
diff --git a/BlazorApp/Program.cs b/BlazorApp/Program.cs
deleted file mode 100644
index e6ef32a..0000000
--- a/BlazorApp/Program.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using BlazorApp;
-using Microsoft.AspNetCore.Components.Web;
-using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
-
-var builder = WebAssemblyHostBuilder.CreateDefault(args);
-builder.RootComponents.Add("#app");
-builder.RootComponents.Add("head::after");
-
-builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
-
-await builder.Build().RunAsync();
diff --git a/BlazorApp/Properties/launchSettings.json b/BlazorApp/Properties/launchSettings.json
deleted file mode 100644
index 81757f8..0000000
--- a/BlazorApp/Properties/launchSettings.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:20186",
- "sslPort": 0
- }
- },
- "profiles": {
- "BlazorApp": {
- "commandName": "Project",
- "launchBrowser": true,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
- "applicationUrl": "http://localhost:5089",
- "dotnetRunMessages": true,
- "nativeDebugging": true
- },
- "IIS Express": {
- "commandName": "IISExpress",
- "launchBrowser": true,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
- }
- }
-}
\ No newline at end of file
diff --git a/BlazorApp/wwwroot/css/open-iconic/FONT-LICENSE b/BlazorApp/wwwroot/css/open-iconic/FONT-LICENSE
deleted file mode 100644
index a1dc03f..0000000
--- a/BlazorApp/wwwroot/css/open-iconic/FONT-LICENSE
+++ /dev/null
@@ -1,86 +0,0 @@
-SIL OPEN FONT LICENSE Version 1.1
-
-Copyright (c) 2014 Waybury
-
-PREAMBLE
-The goals of the Open Font License (OFL) are to stimulate worldwide
-development of collaborative font projects, to support the font creation
-efforts of academic and linguistic communities, and to provide a free and
-open framework in which fonts may be shared and improved in partnership
-with others.
-
-The OFL allows the licensed fonts to be used, studied, modified and
-redistributed freely as long as they are not sold by themselves. The
-fonts, including any derivative works, can be bundled, embedded,
-redistributed and/or sold with any software provided that any reserved
-names are not used by derivative works. The fonts and derivatives,
-however, cannot be released under any other type of license. The
-requirement for fonts to remain under this license does not apply
-to any document created using the fonts or their derivatives.
-
-DEFINITIONS
-"Font Software" refers to the set of files released by the Copyright
-Holder(s) under this license and clearly marked as such. This may
-include source files, build scripts and documentation.
-
-"Reserved Font Name" refers to any names specified as such after the
-copyright statement(s).
-
-"Original Version" refers to the collection of Font Software components as
-distributed by the Copyright Holder(s).
-
-"Modified Version" refers to any derivative made by adding to, deleting,
-or substituting -- in part or in whole -- any of the components of the
-Original Version, by changing formats or by porting the Font Software to a
-new environment.
-
-"Author" refers to any designer, engineer, programmer, technical
-writer or other person who contributed to the Font Software.
-
-PERMISSION & CONDITIONS
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of the Font Software, to use, study, copy, merge, embed, modify,
-redistribute, and sell modified and unmodified copies of the Font
-Software, subject to the following conditions:
-
-1) Neither the Font Software nor any of its individual components,
-in Original or Modified Versions, may be sold by itself.
-
-2) Original or Modified Versions of the Font Software may be bundled,
-redistributed and/or sold with any software, provided that each copy
-contains the above copyright notice and this license. These can be
-included either as stand-alone text files, human-readable headers or
-in the appropriate machine-readable metadata fields within text or
-binary files as long as those fields can be easily viewed by the user.
-
-3) No Modified Version of the Font Software may use the Reserved Font
-Name(s) unless explicit written permission is granted by the corresponding
-Copyright Holder. This restriction only applies to the primary font name as
-presented to the users.
-
-4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
-Software shall not be used to promote, endorse or advertise any
-Modified Version, except to acknowledge the contribution(s) of the
-Copyright Holder(s) and the Author(s) or with their explicit written
-permission.
-
-5) The Font Software, modified or unmodified, in part or in whole,
-must be distributed entirely under this license, and must not be
-distributed under any other license. The requirement for fonts to
-remain under this license does not apply to any document created
-using the Font Software.
-
-TERMINATION
-This license becomes null and void if any of the above conditions are
-not met.
-
-DISCLAIMER
-THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
-OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
-COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
-DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
-OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/BlazorApp/wwwroot/css/open-iconic/ICON-LICENSE b/BlazorApp/wwwroot/css/open-iconic/ICON-LICENSE
deleted file mode 100644
index 2199f4a..0000000
--- a/BlazorApp/wwwroot/css/open-iconic/ICON-LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2014 Waybury
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
\ No newline at end of file
diff --git a/BlazorApp/wwwroot/css/open-iconic/README.md b/BlazorApp/wwwroot/css/open-iconic/README.md
deleted file mode 100644
index 6b810e4..0000000
--- a/BlazorApp/wwwroot/css/open-iconic/README.md
+++ /dev/null
@@ -1,114 +0,0 @@
-[Open Iconic v1.1.1](http://useiconic.com/open)
-===========
-
-### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons)
-
-
-
-## What's in Open Iconic?
-
-* 223 icons designed to be legible down to 8 pixels
-* Super-light SVG files - 61.8 for the entire set
-* SVG sprite—the modern replacement for icon fonts
-* Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats
-* Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats
-* PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px.
-
-
-## Getting Started
-
-#### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections.
-
-### General Usage
-
-#### Using Open Iconic's SVGs
-
-We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute).
-
-```
-
-```
-
-#### Using Open Iconic's SVG Sprite
-
-Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack.
-
-Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `