MATLAB: Dimension mismatch

image processing

I have a set of code ,for some RGB images my codes works but for some the coed not work i get an error "Subscripted assignment dimension mismatch",can u tell how to solve it
size of image1=183 275 3
size of image2=238 174 3
size of image3= 72 72 3
I get error for 2nd and 3rd image but not for 1st image
i grt error in this line
trunCoarseImg(:,:,:) = coarseImg((n+1):(end-n),(n+1):(end-n)); where n=6

Best Answer

You're specifying 3 dimensions for trunCoarseImg but only two for coarseImg. You can't do that. You'd have to assign that 2D coarseImg image to each color plane in trunCoarseImg one at a time.