Photoshop algorithm implementation Advanced-blur filter-motion blur (24)

Source: Internet
Author: User

          Photoshop Algorithm Implementation Advanced-blur filter-motion blur (24)

[Email protected]

Http://blog.csdn.net/kezunhai

The cause of image degradation or blurred image is many, if it is because of the relative motion between the camera and the subject in camera image Blur is called motion blur. The images in the obtained image are often blurred, and we call it motion blur images. Motion Blur is a filter that captures the motion state effect of an object, mainly using the photographic technique of exposure when moving objects, simulating the indirect exposure function of shooting moving object in camera , so that the image can produce a dynamic effect. It is usually used to create the effect of an object passing or moving.

implementation principle: The motion blur filter is in a specific direction and blurs with a specific intensity. First, mathematically, the y-axis is positive, and in the image processing, the y-axis is positive, so when the user-specified direction angle is obtained , it should be rotated 180° along the square, and then the displacement of the image in the specified direction is resolved. Motion is not simply to move an image over a specified image, but rather to copy and overlay pixels in a certain way within a distance-limited range. As a simple matter of view, the multiple copies of an image are stacked in the specified direction and then averaged, and finally, the problem to be solved is the transparency of the image and the processing of the Alpha classification, so that the resulting blurring effect is more desirable.

Implementation algorithm:

Add motion blur effect//angle: The direction of motion, distance: the distance of the movement//here is just a rough calculation, whichever is the length of the DX, or the length of dy or dx+dy//If more accurate calculation is required, please refer to the professional literature void Photoshop::motionblur (mat& img, mat& DST, int angle/* =30 */, int distance/* =100 */) {angle = Angle%360;if (dista nce <1) distance = 1;if (Distance >) distance = 200;double Radian = ((double) angle+180.0)/180.0*pi;  angle to radians int dx = (int) ((double) distance* cos (radian) +0.5); int dy = (int) ((double) distance* sin (radian) +0.5); int sign;if ( dx<0) sign = -1;if (dx>0) sign = 1;int height = img.rows;int width = img.cols;int Chns = Img.channels (); if (Dst.em Pty ()) dst.create (height, width, img.type ()), int i,j, K, I0, J0, p, Sum, count;for (i=0; iTest effect (angle=60, distance = 50):


One more love for the goddess:



The following article describes in detail motion blur, which interested readers can refer to:

1, what is motion blur (motion Blur)

2, high-quality single image motion to blur

KezunhaiSource:Http://blog.csdn.net/kezunhaiWelcome to reprint or share, but be sure to declare the source of the article.

Photoshop algorithm implementation Advanced-blur filter-motion blur (24)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.