【问题标题】:get Blob information with Catalano Framework使用 Catalano 框架获取 Blob 信息
【发布时间】:2013-12-27 19:07:45
【问题描述】:

我正在开发一个应用程序来检测图像中的 blob 或对象。我想从主图像中提取 blob 图像,并在 blob 周围使用边界框。我怎样才能?或者我怎样才能得到斑点的宽度或高度。我的代码:

     btn_process.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            FastBitmap fb, Greench, Redch;
            imageView1.setImageURI(null);
            imageView1.setImageURI(selectedImageUri);
            Bitmap asli = ((BitmapDrawable) imageView1.getDrawable()).getBitmap();
            fb=new FastBitmap(asli);
            ExtractRGBChannel grayGreen=new ExtractRGBChannel(ExtractRGBChannel.Channel.G);
            ExtractRGBChannel grayRed=new ExtractRGBChannel(ExtractRGBChannel.Channel.R);
            Greench=grayGreen.Extract(fb);
            Redch=grayRed.Extract(fb);
            Subtract sub=new Subtract();
            sub.setOverlayImage(Greench);
            sub.applyInPlace(Redch);
            OtsuThreshold otst=new OtsuThreshold();
            otst.applyInPlace(Redch);

            BlobDetection blobDetect=new BlobDetection();
            ArrayList<Blob> blobs=blobDetect.ProcessImage(Redch);
            ExtractBlob eBlobs = new ExtractBlob(blobs);
            Redch = eBlobs.Extract(blobDetect.getIdBiggestBlob(), Redch); 
                            // by this i am reach the biggest blob but with height and width of main image. but i need crop blob image in blob size.



            imageView1.setImageURI(null);
            imageView1.setImageBitmap(Redch.toBitmap());



        }

    });

【问题讨论】:

    标签: android image-processing frameworks


    【解决方案1】:

    我也在 Code Project 中回答了。我在桌面版本中执行此操作,您可以在 android 中进行调整。我将在下一个版本(1.3)中在这两种环境中做一个示例。

    FastBitmap image = new FastBitmap("c:\\files\\blob.png");
    image.toGrayscale();
    
    Threshold t = new Threshold();
    t.applyInPlace(image);
    
    BlobDetection bd = new BlobDetection();
    ArrayList<Blob> blobs = bd.ProcessImage(image);
    
    image.toRGB();
    Graphics g = image.getGraphics();
    g.setColor(Color.red);
    
    for (Blob blob : blobs) {
        ArrayList<IntPoint> lst = PointsCloud.GetBoundingRectangle(blob.getPoints());
    
        int height = Math.abs(lst.get(0).x - lst.get(1).x);
        int width = Math.abs(lst.get(0).y - lst.get(1).y);
    
        g.drawRect(lst.get(0).y, lst.get(0).x, width, height);
    }
    
    JOptionPane.showMessageDialog(null, image.toIcon());
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-05
      相关资源
      最近更新 更多