[Numpy-discussion] Syntax trouble in translating matlab code to numpy
Robert Kern
robert.kern at gmail.com
Thu Apr 12 15:09:12 EDT 2007
Oliver Siemoneit wrote:
> # Transform to LMS space
> LMS = numpy.zeros_like(RGB)
> for i in range(RGB.shape[0]):
> for j in range(RGB.shape[1]):
> rgb = RGB[i,j,:2]
> LMS[i,j,:2] = numpy.dot(rgb2lms, rgb)
>
> This code fails in the last line with the error message "ValueError:
> matrices are not aligned". But how to align them?
You want :3, not :2.
By the way, I have some code that applies a more rigorous model for
colorblindness. The class LinearCorrespondingPairs in this file:
http://www.enthought.com/~rkern/cgi-bin/hgwebdir.cgi/colormap_explorer/file/9955ae141feb/colormap_explorer/vision_model.py
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion
mailing list