小编Fip*_*phe的帖子

如何检测此半导体图像中的缺陷?

所以我有一张半导体晶片的图像,它有一个缺陷,我需要使用 Matlab 检测它。我应该只检测它而不是它的背景。我还需要测量它的周长和面积。

到目前为止,我有这段代码,我将原始图像转换为二进制图像,然后对其使用膨胀,然后尝试获取其轮廓。在获取周长和面积时,我不仅会收到缺陷的结果,还会收到不是我想要的图像其余部分的结果。我怎样才能只提取缺陷,所以我只能得到它的面积和参数。

图片: 这里

fig3 = imread('figure3.png');
imshow(fig3);

title('Original image', 'FontSize', 18);
%Gray image
fig3Gray = rgb2gray(fig3);



%Binary image
BW3 = imbinarize(fig3Gray,0.5);
imshow(BW3);
title('Binary image', 'FontSize', 18);

se3 = strel('square',5);

%Dilation image
dilated3 = imdilate(BW3,sr);
imshow(dilated3);
title('Dilated image', 'FontSize', 18);

minus3 = ~(BW3-dilated3);
imshow(minus3);
title('Contour image', 'FontSize', 18);
imshowpair(minus3,BW3,'montage');

%Perimeter and Area calculation
Coon3 = bwconncomp(~BW3)
ANS3 = length(Coon3.PixelIdxList{1});
OUTPUT3 = regionprops(Coon3,'Perimeter','Area');
P3 = OUTPUT3.Perimeter
Area3 = OUTPUT3.Area
Run Code Online (Sandbox Code Playgroud)

matlab

5
推荐指数
2
解决办法
178
查看次数

如何重载 << 运算符以便将对象的数据写入文件?

我有一个 piggyBank 类型的对象,我需要将此对象的数据写入文件然后读取它。我知道如何写入/读取文本文件,但如何重载 << 运算符,以便将有关对象的数据写入文件?

我的课程代码在这里:

存钱罐.h

#include <string>
#ifndef PIGGYBANK_H
#define PIGGYBANK_H

class PiggyBank
{
 private:
        std::string owner; 
        int balance; 
        bool broken; 
        int id;
        static int nrOfObjects;
    public:
        PiggyBank(void);
        PiggyBank(std::string name);
        std::string getOwnerName() const;
        void setOwnerName(std::string name);
        bool isBroken() ;
        int getBalance(int & amount) ;


};



#endif /* PIGGYBANK_H */
Run Code Online (Sandbox Code Playgroud)

存钱罐.cpp

#include "PiggyBank.h"
#include "readWrite.h"
#include <string>
#include <iostream>
using namespace std;

int PiggyBank::nrOfObjects = 0; // outside constructor


PiggyBank::getNrOfObjects(){

    return nrOfObjects;

}

PiggyBank::PiggyBank(void){
    {this->owner="";this->balance=0;this->broken=false;}
     id = ++nrOfObjects;

} …
Run Code Online (Sandbox Code Playgroud)

c++

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

标签 统计

c++ ×1

matlab ×1