zoukankan      html  css  js  c++  java
  • PS 滤镜——Skewing

    %%%%  Skewing
    
    clc;
    clear all;
    close all;
    
    addpath('E:PhotoShop AlgortihmImage ProcessingPS Algorithm');
    
    Image=imread('4.jpg');
    
    Image=double(Image);
    theta=pi/9;    % 控制倾斜的角度
    [row, col, layer]=size(Image);
    
    % % % % % Horizontal Skewing
    % % row_new=row;
    % % col_new=floor(row*tan(theta))+1+col;
    % % Image_new=zeros(row_new, col_new,3);
    % % Trans=(row-1)*tan(theta);
    % % for i=1:row
    % %     Dis=(row-i)*tan(theta);
    % %     for j=1:col_new
    % %         y0=i;
    % %         % x0=j+Dis-Trans;     %%%%% Left skew
    % %         x0=j-Dis;             %%%%% Right skew
    % %         if(x0>1 && x0<col)
    % %         %     Image_new(i,j)=0;
    % %         x1=floor(x0);
    % %         p=x0-x1;
    % %         Image_new(i,j,:)=(1-p)*Image(y0,x1,:)+p*Image(y0,x1+1,:);
    % %         end
    % %     end
    % % end
    
    
    
    % % % % % Vertical Skewing
    col_new=col;
    row_new=floor(col*tan(theta))+1+row;
     Image_new=zeros(row_new, col_new,3);
     Trans=(col-1)*tan(theta);
    for j=1:col_new
        Dis=j*tan(theta);
            for i=1:row_new
                % y0=i+Dis-Trans;       %%%%% Left skew
                y0=i-Dis;           %%%%% Right skew
                x0=j;
                if(y0>1 && y0<row)
                    %     Image_new(i,j)=0;
                    y1=floor(y0);
                    p=y0-y1;
                    Image_new(i,j, : )=(1-p)*Image(y1,x0, : )+p*Image(y1+1,x0,:);
                end
        end
    end
    
    imshow(Image_new/255);
            


    原图


    水平 skew  theta=pi/6


    垂直 skew theta=pi/9


  • 相关阅读:
    python:(类)私有
    Python:多继承时的继承顺序
    python基础:继承
    年终总结
    cocos版本说明
    WPF学习系列 游戏-选张图片做成9宫格拼图
    SmartAssembly使用失败记录
    WPF学习系列 绘制旋转的立方体
    自适应布局思路
    webfrom 总结
  • 原文地址:https://www.cnblogs.com/mtcnn/p/9412651.html
Copyright © 2011-2022 走看看