À̹ÌÁö¸¦ ´Ü¼ø ÁÂÇ¥¿¡ ÀÇÇؼ È®´ë Ãà¼Ò ÇÏ°Ô µÇ¸é À̹ÌÁö´Â ±úÁø´Ù. À̹ÌÁö¸¦ È®´ë Ãà¼Ò ÇÒ¶§ ¾Ë°í¸®Áò¿¡ ´ëÇؼ ¾Ë¾Æ º¸ÀÚ. ¿©±â¼´Â ´ÙÀ½ ¼¼°¡Áö ¾Ë°í¸®Áò¿¡ ´ëÇؼ Å×½ºÆ® Çغ¸¾Ò´Ù. Bilinear interpolation : ÀÎÁ¢ÇÑ 4°³ÀÇ È¼Ò°ª°ú °Å¸®ºñ¸¦ »ç¿ëÇÑ´Ù. Bicubic interpolation : ÀÎÁ¢ÇÑ 16°³ÀÇ È¼Ò°ª°ú °Å¸®¿¡ µû¸¥ °¡ÁßÄ¡ (weight)ÀÇ °öÀ» »ç¿ëÇÑ´Ù. Lanczos resampling : ÀÌ¿Ü¿¡ ¿©·¯°¡Áö ¾Ë°í¸®ÁòÀÌ ÀÖ´Ù. Nearst Neighbor interpolation : °¡Àå °¡±î¿î ȼҰªÀ» »ç¿ëÇÑ´Ù. B-Spline interpolation : ÀÎÁ¢ÇÑ 16°³ÀÇ È¼Ò°ª°ú °Å¸®¿¡ µû¸¥ °¡ÁßÄ¡ (weight)ÀÇ °öÀ» »ç¿ëÇÑ´Ù. .... ±âŸ µîµî.... OpenCV³ª CxImage¸¦ »ç¿ëÇÏÁö ¾Ê°í Resampling(¿©±â¼´Â Ãà¼Ò) ÇÏ¿´´Ù. RGB 24ºñÆ®·Î Æø°ú ³ÐÀÌ ¸Þ¸ð¸® Æ÷ÀÎÅ͸¸ ÀÎÀÚ·Î ³Ñ°ÜÁÖ¸é º¯È¯ÀÌ µÈ´Ù. void ResizeBilinear(unsigned char pixel[], int w, int h, unsigned char* outTemp, int w2, int h2);
void BlinImageScale(unsigned char* pixelsIn, int w, int h, unsigned char* pixelsOut, int w2, int h2); void BilinearBitmapScale(unsigned char* pixels, int oldPixelWidth, int oldPixelHeight, unsigned char* newPixls, int newPixelWidth, int newPixelHeight); void BicubicResizeImage(unsigned char* in, int src_width, int src_height, unsigned char* out, int dest_width, int dest_height); void BicubicInterpolationImage (const unsigned char* srcImage, int oldWidth, int oldHeight, unsigned char* newPixel, int newWidth, int newHeight); //24bit bitmap load save test void main() { BITMAPINFOHEADER bitmapInfo; BITMAPINFOHEADER newBitmapInfo; unsigned char* pImage = NULL; LoadBitmap("test.bmp", bitmapInfo, pImage); int width = bitmapInfo.biWidth; int height = bitmapInfo.biHeight; newBitmapInfo = bitmapInfo; int newWidth = newBitmapInfo.biWidth = newBitmapInfo.biWidth/2; int newHeight = newBitmapInfo.biHeight = newBitmapInfo.biHeight/2; unsigned char* pNewImage = new unsigned char[newWidth*newHeight*3]; CHECK_TIME_START(err); ResizeBilinear(pImage, width, height, pNewImage, newWidth, newHeight); CHECK_TIME_END(checkTime); if(!err) printf("ResizeBilinear %8.3f ms\r\n", checkTime); SaveBitmap24bitColor("test_bilinear.bmp", pNewImage, newWidth, newHeight); CHECK_TIME_START2; BlinImageScale(pImage, width, height, pNewImage, newWidth, newHeight); CHECK_TIME_END2(checkTime); if(!err) printf("BlinImageScale %8.3f ms\r\n", checkTime); SaveBitmap24bitColor("test_bilinear2.bmp", pNewImage, newWidth, newHeight); CHECK_TIME_START2; BilinearBitmapScale(pImage, width, height, pNewImage, newWidth, newHeight); CHECK_TIME_END2(checkTime); if(!err) printf("BilinearBitmapScale %8.3f ms\r\n", checkTime); SaveBitmap24bitColor("test_bilinear3.bmp", pNewImage, newWidth, newHeight); CHECK_TIME_START2; BicubicResizeImage(pImage, width, height, pNewImage, newWidth, newHeight); CHECK_TIME_END2(checkTime); if(!err) printf("BicubicResizeImage %8.3f ms\r\n", checkTime); SaveBitmap24bitColor("test_Bicubic.bmp", pNewImage, newWidth, newHeight); CHECK_TIME_START2; BicubicInterpolationImage(pImage, width, height, pNewImage, newWidth, newHeight); CHECK_TIME_END2(checkTime); if(!err) printf("BicubicInterpolationImage %8.3f ms\r\n", checkTime); SaveBitmap24bitColor("test_BicubicInterpolation.bmp", pNewImage, newWidth, newHeight); CResizeImage* resizeImage = new CResizeImage(pImage, bitmapInfo, pNewImage, newBitmapInfo); CHECK_TIME_START2; resizeImage->Resize(); CHECK_TIME_END2(checkTime); if(!err) printf("Lanczos resampling %8.3f ms\r\n", checkTime); SaveBitmap24bitColor("test_Lanczos.bmp", pNewImage, newWidth, newHeight); if(resizeImage) delete resizeImage; if(pImage) delete [] pImage; if(pNewImage) delete [] pNewImage; } ResizeBilinear 1.505 msÁÖÀÇ) BicubicResizeImage º¯È¯°ú BilinearBitmapScale º¯È¯µÈ À̹ÌÁö°¡ ÀÏÄ¡ÇÑ´Ù. Bicubic ¸Â´ÂÁö Àǽɽº·´´Ù. ´Ù¿î·Îµå: main.cpp imageScale.cpp image_scale.zip ResizeImage.cpp, ResizeImage.h ÆÄÀÏÀº ÇÁ·ÎÁ§Æ® ¾ÐÃà ÆÄÀÏÀ» ´Ù¿î·Îµå ¹ÞÀ¸¸é µÈ´Ù. Âü°í) ÀÚ¼¼ÇÑ ¼³¸í https://m.blog.naver.com/dudcos101/221421989207 https://m.blog.naver.com/dudcos101/221440411381 ResizeBilinear http://tech-algorithm.com/articles/bilinear-image-scaling/ BlinImageScale https://stackoverflow.com/questions/21250099/c-bilinear-scaling-interpolation-byte-by-byte BilinearBitmapScale https://github.com/cjw1115/BitmapScale/blob/master/图ßÀ缩Û¯/Scale.cs BicubicResizeImage https://stackoverflow.com/questions/15176972/bi-cubic-interpolation-algorithm-for-image-scaling BicubicInterpolationImage https://blog.demofox.org/2015/08/15/resizing-images-with-bicubic-interpolation/ Lanczos resampling https://github.com/tmiddelkoop/ImageResize ¾Ë°í¸®Áò ¿ä¾à ¼³¸í º¤Å͸¦ À̹ÌÁö º¸°£¿¡ ¾î¶»°Ô »ç¿ëÇÏ´ÂÁö ÄÚµå ÀÖÀ½ https://github.com/andresbejarano/ImageInterpolation/blob/master/assignment/main.cpp |