-3

I am working in Python, and I a trying to compute a wight matrix for a graph of pixels, and the weight of each edge is dependent on their "feature" similarity (F(i) - F(j)), and their location similarity (X(i)-X(j)). "Features" includes intensity, color, texture.

Right now I have it implemented and it is working, but not for color images. I at first tried to simply take some RGB values and average each pixel to convert the entire image to greyscale. But that didn't work as I had hoped, and I have read throgh a paper that suggests a different method.

They say to use this: F(i) = [v, v*s*sin(h), v*s*cos(h)](i)

where h, s, and v and the HSV color values.

I am just confused on the notation. What is this suppsed to mean? What does it mean to have three different terms separated by commas inside square brackets? I'm also confused with what the (i) at the end is supposed to mean. The solution to F(i) for any given pixel should be a single number, to be able to carry out F(i)-F(j)?

I'm not asking for someone to do this for me I just need some clarification.

  • 3
    Hello and welcome to StackOverflow. Please take some time to read the help page, especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). And more importantly, please read [the Stack Overflow question checklist](http://meta.stackexchange.com/q/156810/204922). You might also want to learn about [Minimal, Complete, and Verifiable Examples](http://stackoverflow.com/help/mcve). – Morgan Thrapp Jul 22 '15 at 19:31
  • 1
    Sounds like you would benefit from the [official Python tutorial](https://docs.python.org/3.4/tutorial). – TigerhawkT3 Jul 22 '15 at 19:37
  • @MorganThrapp - What is wrong with my question? Care to give me a reason rather than linking to a page that contains every reason possible? –  Jul 22 '15 at 19:40
  • Also, you might want to mention what paper you read and provide some context for the given equation. – TigerhawkT3 Jul 22 '15 at 19:46
  • @TigerhawkT3 "Normalized Cuts and Image Segmentation" by Jianbo Shi and Jitendra Malik. –  Jul 22 '15 at 19:51
  • If it's not Python, how are we supposed to know what kind of syntax the authors were using? In fact, I found it on page 7 [here](http://www.cs.berkeley.edu/~malik/papers/SM-ncut.pdf), and I'm still not sure what they're talking about. Maybe you could provide some more explanation instead of complaining that no one wants to make guesses about the meaning of a context-free equation snippet? – TigerhawkT3 Jul 22 '15 at 19:58
  • Did an admin seriously delete or edit every one of my comments that said something negative about TigerHawkT3? Are you serious? Or did he flag every single one of my comments? All you accomplished, Tiger, was make your last comment sound even more douchey than it did before. The community on this site is toxic –  Jul 22 '15 at 21:35

1 Answers1

2

Features can be vectors and you can calculate distance between vectors.

f1 = numpy.array([1,2,3])
f2 = numpy.array([0,2,3])
distance = numpy.linalg.norm(f1 - f2).
dlask
  • 8,776
  • 1
  • 26
  • 30
  • So youre saying that F(i) does not have to be a single number and can be in vector form, and F(i) - F(j) would still give a sigle number? –  Jul 22 '15 at 20:20
  • [Vector addition](http://mathworld.wolfram.com/VectorAddition.html) (or subtraction) still gives a vector, but you can use the *size* of this resulting vector as that *single number* you are interested in. – dlask Jul 22 '15 at 20:42
  • I see, thanks for your answers! So if I am considering two pixels, each being described in the form of a numpy array with three values ([R,G,B]), I can preform F(i)-F(j) with something like `numpy.linalg.norm(i - j)`? –  Jul 22 '15 at 21:32
  • Keeping `i` and `j` reserved for point identification we can better write: `f1 = numpy.array([1,2,3])`, `f2 = numpy.array([0,2,3])`, and then the distance is `d = numpy.linalg.norm(f1-f2)`. – dlask Jul 23 '15 at 04:40
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Michel Keijzers Jul 23 '15 at 07:56
  • 1
    @MichelKeijzers You are right. I have updated my answer with a Python code illustrating the intention. Thank you. – dlask Jul 23 '15 at 08:01