PS 滤镜— —扇形warp

    clc;
    clear all;
    close all;

    addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm');

    I=imread('4.jpg');
    I=double(I);
    Image=I/255;

    [height, width, depth]=size(Image);

    % set the parameters
    radius = 150;  % control the radius of the inner circle
    high = 200;    % control the distance between the inner circle and outer circle
    angle = 0;             
    spreadAngle=pi;    
    centerX = 0.5;  % set the center of the circle, proportion of the image size
    centerY = 1.0;

    icenterX=width*centerX;
    icenterY=height*centerY;

    Image_new=Image*0;

    for i=1:height
        for j=1:width

            dx=j-icenterX;
            dy=i-icenterY;

            theta=atan2(-dy, -dx)+angle;
            r=sqrt(dy*dy+dx*dx);

            theta=mod(theta, 2*pi);

            x=width * theta/(spreadAngle+0.00001);
            y=height * (1-(r-radius)/(high+0.00001));


    % %         if (x<=1)     x=1;  end
    % %         if (x>=width)   x=width-1; end;
    % %         if (y>=height)  y=height-1; end;
    % %         if (y<1)  y=1;     end;
    % %         

            if (x<=1)     continue;  end
            if (x>=width)   continue; end;
            if (y>=height)  continue; end;
            if (y<1)  continue;     end;


            x1=floor(x);
            y1=floor(y);
            p=x-x1;
            q=y-y1;

            Image_new(i,j,:)=(1-p)*(1-q)*Image(y1,x1,:)+p*(1-q)*Image(y1,x1+1,:)...
                +q*(1-p)*Image(y1+1,x1,:)+p*q*Image(y1+1,x1+1,:);


        end

    end
    imshow(Image_new)
    imwrite(Image_new, 'out.jpg');

参考来源:http://www.jhlabs.com/index.html

原图

这里写图片描述

效果图

这里写图片描述

warp divergence(指变形发散)是计算机图形学中的概念,用于描述在并行计算中的处理器线程之间的差异性。在图形渲染过程中,为了提高性能,常常采用并行计算的方式来对多个像素或顶点进行处理。 然而,不同处理器线程之间的运算速度、内存访问和负载的差异性会导致某些线程完成任务的时间比其他线程更快或更慢。这种差异性被称为warp divergence。 当一个warp(一组连续的线程)中的线程执行不同的代码路径时,就会发生warp divergence。这种情况下,线程无法同时进行计算,需要等待其他线程完成执行,从而影响了整个warp的性能。 常见引起warp divergence的情况包括分支语句(如if/else、switch等),当分支条件不同的时候,不同线程会进入不同的代码分支,从而产生warp divergence。此外,也会发生在访问不连续内存、常量内存的操作中,或者在执行不同的指令集等。 为了避免warp divergence对并行计算的性能造成负面影响,可以采用一些优化技术来减少warp divergence的发生。例如,可以将分支条件相同的线程放在一个warp中,这样它们可以同时执行相同的代码分支。此外,通过合并指令、重新组织数据、考虑内存访问模式等方式,也可以降低warp divergence的风险。 综上所述,warp divergence是计算机图形学中一个重要的概念,用于描述并行计算中处理器线程之间的差异性。理解和优化warp divergence对于提高并行计算性能具有重要意义。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值