fix Affine for 3 channel

This commit is contained in:
jiangzhiwen 2020-09-16 09:55:51 +08:00
parent a5afa6d5ed
commit 18fae4d81e
1 changed files with 3 additions and 3 deletions

View File

@ -613,16 +613,16 @@ void ImplementAffine(LiteMat &src, LiteMat &out_img, double M[6], std::vector<si
IM[2] = b1;
IM[5] = b2;
out_img.Init(dsize[0], dsize[1]);
out_img.Init(dsize[0], dsize[1], sizeof(Pixel_Type));
for (int y = 0; y < out_img.height_; y++) {
for (int x = 0; x < out_img.width_; x++) {
int src_x = IM[0] * x + IM[1] * y + IM[2];
int src_y = IM[3] * x + IM[4] * y + IM[5];
if (src_x >= 0 && src_y >= 0 && src_x < src.width_ && src_y < src.height_) {
Pixel_Type src_pixel = static_cast<Pixel_Type *>(src.data_ptr_)[src_y * src.width_ + src_x];
static_cast<Pixel_Type *>(out_img.data_ptr_)[y * src.width_ + x] = src_pixel;
static_cast<Pixel_Type *>(out_img.data_ptr_)[y * out_img.width_ + x] = src_pixel;
} else {
static_cast<Pixel_Type *>(out_img.data_ptr_)[y * src.width_ + x] = borderValue;
static_cast<Pixel_Type *>(out_img.data_ptr_)[y * out_img.width_ + x] = borderValue;
}
}
}