필터 지우기
필터 지우기

Asign values to pixels

조회 수: 1 (최근 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 CenterFile Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by