Borrar filtros
Borrar filtros

Asign values to pixels

1 visualización (últimos 30 días)
Daniel
Daniel el 7 de Oct. de 2011
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 comentarios
Andrei Bobrov
Andrei Bobrov el 7 de Oct. de 2011
interp1([1 3 9 10],[1 1 5 5],1:10)
Daniel
Daniel el 7 de Oct. de 2011
Thank you!!! That is what I was looking for :)

Iniciar sesión para comentar.

Respuestas (1)

Andrei Bobrov
Andrei Bobrov el 7 de Oct. de 2011
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))

Categorías

Más información sobre Read, Write, and Modify Image en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by