Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

access image after cutting

I have a 600x600 image ( Image) and i am cutting into pieces of 200x200 (piecesImages),by creating 3x3 blocks (Height = 3 , Width =3).

Mat pieceImageFrame (200,200,CV_32F);
vector<Rect> piecesImagesRois;
vector<Mat> piecesImages;
piecesImagesRois.reserve( Width * Height );
piecesImages.reserve( Width * Height );

for( int i = 0; i <ImageSize.height - Height; i+= pieceImageSize.height )
{
    for( int j = 0; j < ImageSize.width - Width; j+= pieceImageSize.width )
    {
        Rect myrect = Rect( j,i, pieceImageSize.width, pieceImageSize.height );
        pieceImageFrame = Image( rect );
        piecesImages.push_back( pieceImageFrame.clone() );
        piecesImagesRois.push_back(rect);             
    }
}

Now, I would expect to be able to access every image until :

piecesImages[ 0 ].at<float>( 199,199)

but as I can see I am able to access:

piecesImages[ 0 ].at<float>( 300,239999 )  !!

I would expect a grabage value but the values seem ok!

access image after cutting

I have a 600x600 image ( Image) and i am cutting into pieces of 200x200 (piecesImages),by creating 3x3 blocks (Height = 3 , Width =3).

Mat pieceImageFrame (200,200,CV_32F);
vector<Rect> piecesImagesRois;
vector<Mat> piecesImages;
piecesImagesRois.reserve( Width * Height );
piecesImages.reserve( Width * Height );

for( int i = 0; i <ImageSize.height - Height; <ImageSize.height; i+= pieceImageSize.height )
) //ImageSize.height = 800
{
    for( int j = 0; j < ImageSize.width - Width; ImageSize.width; j+= pieceImageSize.width )
)//ImageSize.width = 800
    {
        Rect myrect = Rect( j,i, pieceImageSize.width, pieceImageSize.height );
        pieceImageFrame = Image( rect );
        piecesImages.push_back( pieceImageFrame.clone() );
        piecesImagesRois.push_back(rect);             
    }
}

Now, I would expect to be able to access every image until :

piecesImages[ 0 ].at<float>( 199,199)

but as I can see I am able to access:

piecesImages[ 0 ].at<float>( 300,239999 )  !!

I would expect a grabage value but the values seem ok!

access image after cutting

I have a 600x600 image ( Image) and i am cutting into pieces of 200x200 (piecesImages),by creating 3x3 blocks (Height = 3 , Width =3).

Mat pieceImageFrame (200,200,CV_32F);
vector<Rect> piecesImagesRois;
vector<Mat> piecesImages;
piecesImagesRois.reserve( Width * Height );
piecesImages.reserve( Width * Height );

for( int i = 0; i <ImageSize.height; i+= pieceImageSize.height ) //ImageSize.height = 800
600
{
    for( int j = 0; j < ImageSize.width; j+= pieceImageSize.width )//ImageSize.width = 800
600
    {
        Rect myrect = Rect( j,i, pieceImageSize.width, pieceImageSize.height );
        pieceImageFrame = Image( rect );
        piecesImages.push_back( pieceImageFrame.clone() );
        piecesImagesRois.push_back(rect);             
    }
}

Now, I would expect to be able to access every image until :

piecesImages[ 0 ].at<float>( 199,199)

but as I can see I am able to access:

piecesImages[ 0 ].at<float>( 300,239999 )  !!

I would expect a grabage value but the values seem ok!

access image after cutting

I have a 600x600 image ( Image) and i am cutting into pieces of 200x200 (piecesImages),by creating 3x3 blocks (Height = 3 , Width =3).

Mat pieceImageFrame (200,200,CV_32F);
vector<Rect> piecesImagesRois;
vector<Mat> piecesImages;
piecesImagesRois.reserve( Width * Height );
piecesImages.reserve( Width * Height );

for( int i = 0; i <ImageSize.height; i+= pieceImageSize.height ) //ImageSize.height = 600
{
    for( int j = 0; j < ImageSize.width; j+= pieceImageSize.width )//ImageSize.width = 600
    {
        Rect myrect = Rect( j,i, pieceImageSize.width, pieceImageSize.height );
        pieceImageFrame = Image( rect myrect );
        piecesImages.push_back( pieceImageFrame.clone() );
        piecesImagesRois.push_back(rect); piecesImagesRois.push_back(myrect);             
    }
}

Now, I would expect to be able to access every image until :

piecesImages[ 0 ].at<float>( 199,199)

but as I can see I am able to access:

piecesImages[ 0 ].at<float>( 300,239999 )  !!

I would expect a grabage value but the values seem ok!