Asign values to pixels

7 ビュー (過去 30 日間)
Daniel
Daniel 2011 年 10 月 7 日
Hello,
I have one question. I want to assign values to pixels between a Maximum and a Minimum. Let me explain better. I am working on an edge detection code. In one of its part, I evaluate an edge profile after applying the gradient(i.e. 10 positions of pixels). Then I find in this 10 positions the maximum and the minimum value and its position too. Finally from position 1 until the position of the minimum I assign the minimum value for all pixels, and the same for the maximum starting at the end of the profile (remember, 10). So, for example I found that the pixel in position 3 is the minimum, so I assign from 1 to 3 this value. And the max in position 9, so from 10 to 9 value max is assigned. Now my question is how I can give a value to the pixels situated in positions 4,5,6,7 and 8 to connect the minimum value to the maximum value. The idea is if I plot this after doing this process is to see like two constants (straight line, one for max and one for min) and then, for connecting both lines,line with a pendent.
I think that interpolation is a good way but I do not really know how to do it.
It seems difficult explained like that but I hope you can understand what I am meaning.
Thank you very much!
regards
daniel
  2 件のコメント
Andrei Bobrov
Andrei Bobrov 2011 年 10 月 7 日
interp1([1 3 9 10],[1 1 5 5],1:10)
Daniel
Daniel 2011 年 10 月 7 日
Thank you!!! That is what I was looking for :)

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

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2011 年 10 月 7 日
variant
x = rand(1,10)
[v,i12]=sort(x)
out = interp1([1 i12([1,end])-[-eps,eps] numel(x)],[1;1]*v([1,end]),1:numel(x))
edited
x = rand(1,10)
[v,i12]=sort(x)
[a b] = unique([1 i12([1,end]) numel(x)])
p = [1;1]*v([1,end])
out = interp1(a,p(b),1:numel(x))

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by