如何使用MATLAB Image Processing计算锥形喷雾图像(2D)一半长度的面积?

时间:2019-07-13 03:27:55

标签: image matlab image-processing

我有一张燃油喷雾的图像,我想找到燃油喷雾的角度。我正在阅读的一篇研究论文告诉我,我可以使用喷雾一半长度的面积来找到角度,而现在我已经尝试寻找一半长度的面积了几周。

以下代码显示了我尝试过的内容。我还尝试了其他方法,例如修剪掉所有非零元素并仅从喷涂结束算起角度。由于这给了我一个不正确的答案,因此我在这里寻求帮助。

class HaveSubject {
    // Angular service
    public mySubject$: Subject<string> = new Subject<string>();
    private workDone$: Subject<void> = new Subject<void>();

    imDone() {
        this.workDone$.next();
    }

    public codeImExecuting() {
        if (this.mySubject$.observers.length) { // check for observers
            // if observers, listen for that many emissions from workDone$, only reacting to the last one
            this.workDone$.pipe(take(this.mySubject$.observers.length), last())
                          .subscribe(v => this.somethingVeryImportant());
        } else { // or just run the function, doesn't matter
            this.somethingVeryImportant();
        }
        this.mySubject$.next('input for tasks');

    }

    private somethingVeryImportant() {
        // stuff
    }
}

我期望喷雾角度在20度左右。

test image

1 个答案:

答案 0 :(得分:0)

为了更好地估计宽度(喷涂角度)的变化,您可能需要在整个图像上放置一条线

[h w] = size(BW2);
margin = ceil(h/10);  % ignore top/bottom parts
row_width = sum(BW2(margin:end-margin,:), 2);  % number of white pixel in each row
x = 1:numel(row_width);
pp = polyfit(x, row_width.', 1);  % fit a line

% see the line
figure; 
plot(row_width); 
hold all;
plot(x, x*pp(1) + pp(2));

% get the angle (in degrees)
angle = atan(pp(1)) * 180 / pi 

估计角度为

7.1081

剧情:
enter image description here