Problem 46833. Roots, Bloody Roots: part 1/2
Solution Stats
Problem Comments

9 Comments
Hi, I have tried a first solution. Since I see only the hash value of the correct solution and not the solution itself, I am not sure how to finalize my code.. So, some questions:
(1) where exactly is the zero angle? The text says on the real line (which should be to the right?) the picture suggests to the bottom (isn't red equal to zero angle in HSV?)
(2) what exactly is beta? The text says "norm" > I assumed Euclidean norm. is this correct?
(3) does the test suite account for numerical noises due to different implementations, or is it just a hash of the reference solution?
Thanks. :)
Thanks for the feedback, Alex.
(1) The zero angle in the HSV space is given by the color red. So it is positioned on the vertical axis at the figure's center, and the angle increases counterclockwise.
(2) You are right to assume that beta is the euclidean norm, I've checked your solutions for V, and they are correct (as well as S, of course). The problem seems to be with your angle (H). I am not sure you can determine the right angle by using just asin. I believe you need to use atan, or both asin and acos to find the right angle quadrant.
(3) You are right. I've forgotten to take into account the noise, sorry about that. When I was designing this problem, I was thinking about using uint8 to remove noise, but in the end, I didn't. So I will fix the test suite to consider only 4 decimal places or use uint8 and update the problem description when I'm finished.
Hi, I have been trying the solution for a while. Will the solution be incorrect if I used 'hsv2rgb' function of matlab?
Hi, Ratul, yes, you can use hsv2rgb function, but there seems to be a problem with the test suite. Please, wait a while, I will fix everything and update the problem description today.
All problems are fixed now, sorry Ratul and Alex for any issues that you had. RGB values should be rounded to 4decimal places. And remove NaNs from your results if present. Let me know if you still experience issues, or if you want a tip (I've fixed some of your codes, and they passed the test suite).
Example image is not correct, since hue equal 0 corresponds to primary red color. Please correct.
(https://en.wikipedia.org/wiki/Complex_plane states that real axis is pointing to the left, not to the bottom)
Also it would be great if you add additional checks in test cases, from which we can understand how our solution differs from yours.
For example: check correct value for some points of resulting image (like corners or real/imaginari axis points).
Svyatoslav Golousov, the real axis pointing left is only a convention. However, I will change the problem description later to explain it as I did on the next one. And I will think of a way to measure the similarity between images. I agree it's essential to provide better feedback; thanks for the suggestion.
Hi, Rafael.
I tried your problem and my solution only passed test suite #3.
I used complex number to represent the coordinates. From that, I computed abs() and angle().
I assumed that row m is corresponding to positive yaxis, and column n is positive xaxis.
For m or n is odd, the center is exactly the midpoint of the array 1:m or 1:n,
but for m or n is even, I put two elements for each for the origin.
Therefore, we have 2x2 array for the origin when m and n is even
or 2x1 if m is even and n is odd, or 1x2 m is odd or n is even.
Before that I also tried with simple origin by taking the floor(([m, n]+1)/2).
Unfortunately, those two approaches didn't give the same results as yours.
I plot the `cp` array (m x n x 3) using `image` and the plot is same as your
image.
I also flip the each HSV array, because Matlab use the convention for angle
start from pi to pi (in this problem it points to negative y axis).
Thank you.
Solution Comments

5 Comments
This solution will pass the test suite if you remove the offset of pi/2, convert values to RGB, and round them to 4 decimal places.
Perfect! Thanks for the update, now it works. :)
No problem. :)
Finally solved it. Thanks Rafael.
Excellent, Ratul, congrats. And No problem.
Problem Recent Solvers4
Suggested Problems

given 3 sides, find area of this triangle
739 Solvers

The Hitchhiker's Guide to MATLAB
3088 Solvers

373 Solvers

455 Solvers

215 Solvers
More from this Author5
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!