【解決方法】C# と aforge.net の画像からロゴを削除するにはどうすればよいですか?

プログラミングQA


C# と AForge.NET を使用して画像からロゴを削除しようとしていますが、オープン チャット gpt から取得したコードがコンパイルされません。 このコードを完成させて画像からロゴを削除するのを手伝ってください

私が試したこと:

<pre lang="C#">

<pre>Bitmap map = (Bitmap)pictureBox1.Image;
        //load the input image
        /*Image<Bgr, Byte> inputImage = new Image<Bgr, Byte>(map);
        //create a log mask with a path clearly defined to where the file is
        Image<Gray, Byte> mask = new Image<Gray, Byte>(inputImage.Width, inputImage.Height);
        //path to the image
        mask.SetValue(new Gray(255), new Image<Gray, Byte>("C:\\Users\\99ENT$TECH\\Pictures\\logo2.jpg"));
        Image<Bgr, Byte> outputImage = inputImage.InPaint(mask, 3);
        //assign the image to picture box 2
        */
        //convert image to gray scale;
        Grayscale grayscaleFilter = new Grayscale(0.2125, 0.7154, 0.0721);
        Bitmap grayImage = grayscaleFilter.Apply(map);
        pictureBox2.Image = grayImage;
        //smoothen the image using a gaussian blur
        GaussianBlur blurFilter = new GaussianBlur(5, 11);
        Bitmap blurImage = blurFilter.Apply(grayImage);
        // Use the Canny edge detection algorithm to detect the edges in the image
        CannyEdgeDetector edgeFilter = new CannyEdgeDetector();
        Bitmap cannyFilter = edgeFilter.Apply(blurImage);
        // Find the contours in the image
        BlobCounter blobCounter = new BlobCounter();
        blobCounter.MinWidth = 10;
        blobCounter.MinHeight = 10;
        blobCounter.FilterBlobs = true;
        blobCounter.ProcessImage(blurImage);
        Blob[] blobs = blobCounter.GetObjectsInformation();

// Select the contour that corresponds to the logo
        int index = 0; // replace with the index of the contour that corresponds to the logo
        Blob blob = blobs[index];

// Create a mask for the logo
        blobCounter.ExtractBlobsImage(blurImage,blob, true);

// Invert the mask
        Invert invertFilter = new Invert();
        invertFilter.ApplyInPlace(cannyFilter);

// Remove the logo from the image by applying the mask to the original image
        ExtractChannel extractFilter = new ExtractChannel();
        Bitmap result = extractFilter.Apply(blurImage);

        pictureBox2.Image = result;

解決策 1

一般的に、ChatGPT のコードはコンパイルされず、コンパイルされても機能しません。最近、かなりの数のコードが見られます。

画像からロゴを削除することは、ほぼ確実に画像がリリースされた条件に違反しているため、悪意のある動作になります。

私たちは、悪意のあるコードの作成を容認、サポート、または支援することはありません。 これは、プロの開発者向けの専門サイトです。

そのようなものを作成する方法を知りたい場合は、ハッキング サイトにアクセスする必要があります。ただし、最初にすべてのファイアウォールとウイルス対策製品を無効にしてください。そうしないと、十分に信頼されなくなります。

コメント

タイトルとURLをコピーしました