New sharpen filter and a new option to select the filter

This commit is contained in:
Carter committed 2026-08-17 11:18:11 -04:00
1 parent 6a07ba666b
commit afd3972c6f
2 files changed
+45 -4

No files matched your search

+4
View File
@@ -23,6 +23,10 @@ namespace VideoProcessor
Filters edges = new Filters(); Filters edges = new Filters();
edges.Edges(); edges.Edges();
break; break;
case "sharpen":
Filters sharpen = new Filters();
sharpen.Sharpen();
break;
default: default:
+41 -4
View File
@@ -8,11 +8,12 @@ namespace VideoProcessor
class Filters class Filters
{ {
/// <summary> /// <summary>
/// /// Creates a grey scale image and every pixel with a vule inside a range is changed to blue and
/// every other pixel is changed to green
/// </summary> /// </summary>
public void ColorSwap() public void ColorSwap()
{ {
VideoCapture capture = new VideoCapture(); VideoCapture capture = new VideoCapture(0);
Mat frame = new(); Mat frame = new();
bool pause = false; bool pause = false;
@@ -56,11 +57,11 @@ namespace VideoProcessor
} }
/// <summary> /// <summary>
/// /// Uses canny edge ditection to find and display all the edges in a frame
/// </summary> /// </summary>
public void Edges() public void Edges()
{ {
VideoCapture capture = new VideoCapture(); VideoCapture capture = new VideoCapture(0);
Mat feed = new Mat(); Mat feed = new Mat();
Mat guassianBlur = new Mat(); Mat guassianBlur = new Mat();
Mat cannyFeed = new Mat(); Mat cannyFeed = new Mat();
@@ -87,5 +88,41 @@ namespace VideoProcessor
} }
} }
} }
/// <summary>
///
/// </summary>
public void Sharpen()
{
VideoCapture capture = new();
Mat feed = new();
Mat sharpendFeed = new();
bool play = false;
float[,] kernalArray = new float[3, 3]
{
{ 0, -1, 0},
{ -1, 5, -1},
{ 0, -1, 0}
};
ConvolutionKernelF kernal = new ConvolutionKernelF(kernalArray);
while(!play)
{
capture.Read(feed);
CvInvoke.Filter2D(feed, sharpendFeed, kernal, new Point(0, 0));
CvInvoke.Imshow("Sharpend Video", sharpendFeed);
int keyPressed = CvInvoke.WaitKey(1);
if (keyPressed == 27)
{
play = true;
}
}
}
} }
} }