Asign values to pixels
1 次查看(过去 30 天)
显示 更早的评论
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
回答(1 个)
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))
0 个评论
另请参阅
类别
在 Help Center 和 File 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!