Hello. I am using the Images package to do some processing. I have an RGB image img, and I’d like to create a view such that I can index channels by name. My idea was to derive view slices from the channelView:
And regarding the question of how to change the Dict type, that depends.
If you want the changes to the dict values to reflect on the original cv, you should have the dict as it is and modify its elements in-place. If you just want to split the image into three channels, then use cv[i,:,:] - as you have noticed, it will work, but you may need additional work to join the channels back into one image.
I read that part of the documentation. But in my case I’m talking about the lefthand side slice, i.e. non-copy assignment. The purpose of my view dictionary was to replace the lefthanded cv [1,:,:] = some_floatarray indexing with a more meaningful view indexing: cv["red"] = some_floatarray.
change the array (or view) stored in the Dictionary for another one. If you want to change its values, not changing it for another one (because in that case the original array is not updated) you must use .= as it was previouosly suggested (".=" copy all the elements).
If it does not solve your question, I do not actually understand what you want to do.
It sounds like you might be coming from C++, where doing y = x may actually mutate y by copying the contents of x into it. Julia doesn’t work that way–doing y = x just attaches the label y to the value of x, disregarding whatever value may have been previously attached to y. If you want to mutate the array which is currently labeled myview["red"], then you want .= which does actually modify the array elements rather than just changing a label.