小编use*_*394的帖子

如何为 UIImage 中的透明孔着色

我有一个PNG带有内部透明像素的孔的图像,我尝试了很多方法来改变“孔颜色”。我认为的解决方案是制作一个具有 png 图像形状的彩色蒙版并将其放在原始图像后面,但我不知道如何制作这个。

做到这一点的懒惰方法是改变UIImageView背景颜色,但UIImageView背景方块会在那里,并且我也改变透明区域的颜色得到相同的结果。我想要的只是PNG使用 Swift 更改图像内的透明孔

uikit uiimage ios swift

3
推荐指数
1
解决办法
2594
查看次数

OpenCV检测最大宽度的矩形

我试图从该图像中获取这个矩形: 想要矩形

使用 OpenCV 找到了这个解决方案:

 private Bitmap findRectangle(Bitmap src) throws Exception {
        Mat imageMat = new Mat();
        Utils.bitmapToMat(src, imageMat);

        Mat imgSource=imageMat.clone();

        Imgproc.cvtColor(imgSource, imageMat, Imgproc.COLOR_BGR2GRAY);

        //find the contours
        List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
        Imgproc.findContours(imageMat, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_NONE);

        Imgproc.Canny(imageMat,imageMat,0,255);
        Bitmap canny=Bitmap.createBitmap(imageMat.cols(),imageMat.rows(),Bitmap.Config.ARGB_8888);
        Utils.matToBitmap(imageMat,canny);

        Imgproc.GaussianBlur(imageMat, imageMat, new  org.opencv.core.Size(1, 1), 2, 2);
        Bitmap blur=Bitmap.createBitmap(imageMat.cols(),imageMat.rows(),Bitmap.Config.ARGB_8888);
        Utils.matToBitmap(imageMat,blur);

        MatOfPoint temp_contour = contours.get(0); //the largest is at the index 0 for starting point

        for (int idx = 0; idx < contours.size(); idx++) {
            temp_contour = contours.get(idx);
            //check if …
Run Code Online (Sandbox Code Playgroud)

java android opencv

2
推荐指数
1
解决办法
2406
查看次数

标签 统计

android ×1

ios ×1

java ×1

opencv ×1

swift ×1

uiimage ×1

uikit ×1