Separate region by an equation

1 回表示 (過去 30 日間)
Hg
Hg 2015 年 11 月 2 日
編集済み: Ced 2015 年 11 月 2 日
How to separate a region by an equation. For example I want to find the region greater than the equation y = mx + c.
  1 件のコメント
Ced
Ced 2015 年 11 月 2 日
編集済み: Ced 2015 年 11 月 2 日
How is your image saved?
If you have e.g. matrix A with the pixel values for each (x,y) pair, and you want all the pixels above y = mx + c (i.e. y - m*x - c > 0) to be zero, then:
m = -1;
c = 1;
x = 0:0.01:1; % your x values
y = 0:0.01:1; % your y values
% logical matrix for each x/y pair
logical_matrix = false(length(x),length(y));
for i = 1:length(x) % for each x value
for j = 1:length(y) % for each y value
logical_matrix(i,j) = (y(j) - m*x(i) - c > 0);
end
end
% now set corresponding values in your A matrix to the desired value
A(logical_matrix) = 0;
You can of course do this more efficiently without for loops, but the exact form will depend on how you saved your matrix/object/whatever it is you have.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by