Вопрос

Can somebody help me fix this index out of bounds error in that happens when calcification_image into a region of contour_image located around the center ?? The code is in matlab

function [final_image] = addCalcificationToContour(contour_image, calcification_image)
final_image=contour_image;
calcificationI=1;
calcificationJ=1;
contour_image_size=size(contour_image)
calcification_image_size=size(calcification_image)
    for finalImageI=int32(size(contour_image,2)/2)-size(calcification_image,2)/2:int32(size(contour_image,2)/2+size(calcification_image,2)/2)-1
        calcificationI=calcificationI+1;
        calcificationJ=1;
        for finalImageJ=int32(size(contour_image,1)/2)-size(calcification_image,1)/2:int32(size(contour_image,1)/2+size(calcification_image,1)/2)-1

            final_image(finalImageI,finalImageJ)=calcification_image(calcificationI,calcificationJ);

            calcificationJ=calcificationJ+1;
        end
    end
figure;imshow(calcification_image);
end

The error message produced is the following:

Attempted to access calcification_image(241,1); index out of bounds because size(calcification_image)=[240,305,3].

Error in addCalcificationToContour (line 12) final_image(finalImageI,finalImageJ)=calcification_image(calcificationI,calcificationJ);

Это было полезно?

Решение

I fixed the errors by rewriting the code... Not only I did not handle RGB Colours, I had also used inverse row and column coordinates...

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top