new_img is ==>
new_img = zeros(height, width, 3);
curMean is like this: [double, double, double]
new_img(rows,cols,:) = curMean;
so what is wrong here?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The line:
will only work if
rowsandcolsare scalar values. If they are vectors, there are a few options you have to perform the assignment correctly depending on exactly what sort of assignment you are doing. As Jonas mentions in his answer, you can either assign values for every pairwise combination of indices inrowsandcols, or you can assign values for each pair[rows(i),cols(i)]. For the case where you are assigning values for every pairwise combination, here are a couple of the ways you can do it:Break up the assignment into 3 steps, one for each plane in the third dimension:
You could also do this in a for loop as Jonas suggested, but for such a small number of iterations I kinda like to use an “unrolled” version like above.
Use the functions RESHAPE and REPMAT on
curMeanto reshape and replicate the vector so that it matches the dimensions of the sub-indexed section ofnew_img:For an example of how the above works, let’s say I have the following:
Either of the above solutions will give you this result: