Michael Hanke schrieb: >Ok. Now that you have said "A" I would ask that you should also say "B": Would >it be possible to get a copy of your filter for experimenting, ideally with >adescription of the theory behind it since you said it's non-standard. > OK, here we go...
This is a much simplified and a lot faster variant of that scaler. It took me some minutes to make it useful and understandable... (I hope)... void upscale (uint8_t * dst, uint8_t * src, int w, int h) { // triangulation scaler // this scaler works by analysing the correlations between neighboring pixels // it is a rather simple "super-resolution-approach" but as TV is lowpassfiltered // in front of transmission we can't recover resolution with a multi-image approach // so if upscaling is needed at all, we try to do it visually correct... // // the results are quite similar to what modern plasma-screens do with SD-signals int x, y; int dx, dy; int m; int a, b, c, d; int ae, be, ce, de, me; for (y = 0; y <= h; y++) for (x = 0; x <= w; x++) { *(dst + (x * 2) + (y * 2) * (w * 2)) = *(src + x + y * w); } w *= 2; h *= 2; for (y = 1; y <= h; y += 2) for (x = 1; x <= w; x += 2) { // fill in the four neighbor-pixels a = *(dst + (x - 1) + (y - 1) * w); b = *(dst + (x + 1) + (y - 1) * w); c = *(dst + (x - 1) + (y + 1) * w); d = *(dst + (x + 1) + (y + 1) * w); // calculate the mean of the neighbors m = (a + b + c + d) / 4; // calculate the error for every neighbor-pixel ae = (m - a) * (m - a); be = (m - b) * (m - b); ce = (m - c) * (m - c); de = (m - d) * (m - d); // find the maximum error-value me = ae; me = (me < be) ? be : me; me = (me < ce) ? ce : me; me = (me < de) ? de : me; // generate mixing coefficients ae = me - ae; be = me - be; ce = me - ce; de = me - de; me = ae + be + ce + de; if (me != 0) m = (a * ae + b * be + c * ce + d * de) / me; *(dst + x + y * w) = m; } for (y = 0; y <= h; y += 2) for (x = 1; x <= w; x += 2) { // fill in the four neighbor-pixels a = *(dst + (x - 1) + y * w); b = *(dst + (x + 1) + y * w); c = *(dst + x + (y - 1) * w); d = *(dst + x + (y + 1) * w); // calculate the mean of the neighbors m = (a + b + c + d) / 4; // calculate the error for every neighbor-pixel ae = (m - a) * (m - a); be = (m - b) * (m - b); ce = (m - c) * (m - c); de = (m - d) * (m - d); // find the maximum error-value me = ae; me = (me < be) ? be : me; me = (me < ce) ? ce : me; me = (me < de) ? de : me; // generate mixing coefficients ae = me - ae; be = me - be; ce = me - ce; de = me - de; me = ae + be + ce + de; if (me != 0) m = (a * ae + b * be + c * ce + d * de) / me; *(dst + x + y * w) = m; } for (y = 1; y <= h; y += 2) for (x = 0; x <= w; x += 2) { // fill in the four neighbor-pixels a = *(dst + (x - 1) + y * w); b = *(dst + (x + 1) + y * w); c = *(dst + x + (y - 1) * w); d = *(dst + x + (y + 1) * w); // calculate the mean of the neighbors m = (a + b + c + d) / 4; // calculate the error for every neighbor-pixel ae = (m - a) * (m - a); be = (m - b) * (m - b); ce = (m - c) * (m - c); de = (m - d) * (m - d); // find the maximum error-value me = ae; me = (me < be) ? be : me; me = (me < ce) ? ce : me; me = (me < de) ? de : me; // generate mixing coefficients ae = me - ae; be = me - be; ce = me - ce; de = me - de; me = ae + be + ce + de; if (me != 0) m = (a * ae + b * be + c * ce + d * de) / me; *(dst + x + y * w) = m; } // only very little lowpass-filtering (sometimes looks better sometimes not...)... #if 0 for (y = 0; y <= h; y++) for (x = 0; x <= w; x++) { a = *(dst + (x - 1) + (y - 1) * w); b = *(dst + (x + 1) + (y - 1) * w); c = *(dst + (x - 1) + (y + 1) * w); d = *(dst + (x + 1) + (y + 1) * w); m = (a + b + c + d) / 4; m += *(dst + x + y * w) * 3; m /= 4; *(dst + x + y * w) = m; } #endif } -- Gnomemeeting/Netmeeting: callto:ils.seconix.com/[EMAIL PROTECTED] ICQ: 131490319 ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ Mjpeg-users mailing list Mjpeg-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mjpeg-users