c# - Optimize pixel image comparison using emgu cv libraries instead of for loops -
i'm working on invisible watermarking c# project.
requirement embed watermark image cover image based on comparing each watermark image pixel each cover image pixel
based on threshold value.i have used 4 for-loops iterating through watermark image and
cover image. works smaller image (ie: 30x30
pixels), need optimize bigger images , find best fitting place of watermark pixel in cover image location.i know not optimum way, instead of loops need suggestion of best library use in emgu cv in c# these easily.
please suggest way optimize piece of code bigger images. thanks.
// iterate through watermark_img (int x = 0; x < watermark_img.height; x++) { (int y = 0; y < watermark_img.width; y++) { //iterate through cover image (int = 0; < cover.height; i++) { (int j = 0; j < cover.width; j++) { bgr pixel_watermark = watermark_img[x, y]; bgr pixel_cover = cover[i, j]; //get watermark pixel color values double b_wm = pixel_watermark.blue; double g_wm = pixel_watermark.green; double r_wm = pixel_watermark.red; //get cover image pixel color values double b_cov = pixel_cover.blue; double g_cov = pixel_cover.green; double r_cov = pixel_cover.red; //diff double b_diff = math.abs(b_wm - b_cov); double g_diff = math.abs(g_wm - g_cov); double r_diff = math.abs(r_wm - r_cov); //determine threshold ====== 7 (last 3 bits) int threshold = 7; if ((b_diff <= threshold) && (g_diff <= threshold) && (r_diff <= threshold)) { flag = true; count_hit[cnt - 1]++; //messagebox.show("no of pixels qualified embedding =\t", count_hit.tostring(), messageboxbuttons.ok); } else { flag = false; count_miss[cnt - 1]++; // messagebox.show("pixel count lesser threshold =\t", count_miss.tostring(), messageboxbuttons.ok); }
Comments
Post a Comment