Ilia Gildin
Junior Member level 3
Hello
I have a huge code that doesn't really matter but I have my ROI of B2(boundRect1) but if its larger then 36 pixels in length or height I have to crop it (resize does not help me as it is downgrade quality) when I try to "crop" this image I get an error or black image or image on the original size the already tried ways are:
B2(boundRect1)(Rect(round((boundRect1.width -36) / 2), round((boundRect1.height -36) / 2), round((boundRect1.width -36) / 2) + 36, round((boundRect1.height -36) / 2) + 36)
or saving the B2(boundRect1) to temp matrix and temp(Rect(round((boundRect1.width -36) / 2), round((boundRect1.height -36) / 2), round((boundRect1.width -36) / 2) + 36, round((boundRect1.height -36) / 2) + 36)
or using the Point center = (boundRect1.br() + boundRect1.tl()) * 0.5; to find the center point of the original rectangle and then using
Mat temp1 = Mat::zeros(Size(boundRect1.width,boundRect1.height), CV_8UC3);
for (int i1 = center.x - 18; i1 < center.x + 18; i1++)
{
for(int j1 = 0; j1 < boundRect1.height; j1++)
{
temp1.at<int>(i1,j1) = 1;
}
}
Mat bwCrop1 = Mat::zeros(Size(36,36),CV_8UC3);
bitwise_and(temp1, temp, bwCrop1);
where temp is the original B2(boundRect1) matrix
but it still wont work
thanks in advanced
I have a huge code that doesn't really matter but I have my ROI of B2(boundRect1) but if its larger then 36 pixels in length or height I have to crop it (resize does not help me as it is downgrade quality) when I try to "crop" this image I get an error or black image or image on the original size the already tried ways are:
B2(boundRect1)(Rect(round((boundRect1.width -36) / 2), round((boundRect1.height -36) / 2), round((boundRect1.width -36) / 2) + 36, round((boundRect1.height -36) / 2) + 36)
or saving the B2(boundRect1) to temp matrix and temp(Rect(round((boundRect1.width -36) / 2), round((boundRect1.height -36) / 2), round((boundRect1.width -36) / 2) + 36, round((boundRect1.height -36) / 2) + 36)
or using the Point center = (boundRect1.br() + boundRect1.tl()) * 0.5; to find the center point of the original rectangle and then using
Mat temp1 = Mat::zeros(Size(boundRect1.width,boundRect1.height), CV_8UC3);
for (int i1 = center.x - 18; i1 < center.x + 18; i1++)
{
for(int j1 = 0; j1 < boundRect1.height; j1++)
{
temp1.at<int>(i1,j1) = 1;
}
}
Mat bwCrop1 = Mat::zeros(Size(36,36),CV_8UC3);
bitwise_and(temp1, temp, bwCrop1);
where temp is the original B2(boundRect1) matrix
but it still wont work
thanks in advanced