zoukankan      html  css  js  c++  java
  • 将图像的代数中心转移到几何中心上

    function  k2  = CenPtran( k,m,n)
    %UNTITLED Summary of this function goes here
    %   Detailed explanation goes here
    centerGPos = cenP(k);
    centerGPos1 = [floor(m/2)+1,floor(n/2)+1];
    if mod(abs(centerGPos(1)-centerGPos1(1)),2) == 0 && mod(abs(centerGPos(2)-centerGPos1(2)),2) ==0
        k1 = zeros(m+abs(centerGPos(1)-centerGPos1(1)),n+abs(centerGPos(2)-centerGPos1(2)));
    elseif  mod((centerGPos(1)-centerGPos1(1)),2) == 0&&mod(abs(centerGPos(2)-centerGPos1(2)),2) ~=0
        k1 = zeros(m+abs(centerGPos(1)-centerGPos1(1)),n+abs(centerGPos(2)-centerGPos1(2))+1);
    elseif  mod((centerGPos(2)-centerGPos1(2)),2) ==0&&mod((centerGPos(1)-centerGPos1(1)),2) ~= 0
        k1 = zeros(m+abs(centerGPos(1)-centerGPos1(1))+1,n+abs(centerGPos(2)-centerGPos1(2)));
    else
        k1 = zeros(m+abs(centerGPos(1)-centerGPos1(1))+1,n+abs(centerGPos(2)-centerGPos1(2))+1);
    end
    [k1m k1n] = size(k1);
    if centerGPos(1)-centerGPos1(1)>= 0 && centerGPos(2)-centerGPos1(2)>=0
        for ki =1:m
            for kj =1:n
                k1(ki,kj) = k(ki,kj);              
            end
        end
    elseif centerGPos(1)-centerGPos1(1)<0 && centerGPos(2)-centerGPos1(2)==0
        for ki = (abs(centerGPos(1)-centerGPos1(1))+1):(abs(centerGPos(1)-centerGPos1(1))+m)
            for kj =1:k1n
                k1(ki,kj) = k(ki-abs(centerGPos(1)-centerGPos1(1)),kj);               
            end
        end
    elseif centerGPos(2)-centerGPos1(2)<0&&centerGPos(1)-centerGPos1(1)== 0
        for ki = 1:k1m
            for kj =( (abs(centerGPos(2)-centerGPos1(2)))+1):((abs(centerGPos(2)-centerGPos1(2)))+n)
                k1(ki,kj) = k(ki,kj-abs(centerGPos(2)-centerGPos1(2)));               
            end
        end
    elseif  centerGPos(1)-centerGPos1(1)<0&& centerGPos(2)-centerGPos1(2)>0 
         for ki = (abs(centerGPos(1)-centerGPos1(1))+1):(abs(centerGPos(1)-centerGPos1(1))+m)
            for kj =1:n
                k1(ki,kj) = k(ki-abs(centerGPos(1)-centerGPos1(1)),kj);               
            end
         end
    elseif centerGPos(1)-centerGPos1(1)>0&& centerGPos(2)-centerGPos1(2)<0 
            for ki =1:m
                for kj =( (abs(centerGPos(2)-centerGPos1(2)))+1):((abs(centerGPos(2)-centerGPos1(2)))+n)
                    k1(ki,kj) = k(ki,kj-abs(centerGPos(2)-centerGPos1(2)));               
                end
            end
    else
        for ki = (abs(centerGPos(1)-centerGPos1(1))+1):(abs(centerGPos(1)-centerGPos1(1))+m)
            for kj =( (abs(centerGPos(2)-centerGPos1(2)))+1):((abs(centerGPos(2)-centerGPos1(2)))+n)
                k1(ki,kj) = k(ki-abs(centerGPos(1)-centerGPos1(1)),kj-abs(centerGPos(2)-centerGPos1(2)));               
            end
        end
    end
    centerGPos2 = cenP(k1);
    x1 = centerGPos2(1)-floor(m/2);
    x2 = x1+2*floor(m/2);
    y1 =  centerGPos2(2)-floor(n/2);
    y2 = y1+2*floor(n/2);
    k2 = k1(x1:x2,y1:y2);
  • 相关阅读:
    Android 手势检测实战 打造支持缩放平移的图片预览效果(下)
    二. 200多万元得到的创业教训--令人又爱又恨的外包
    一. 200多万元得到的创业教训--产品篇
    Android 手势检测实战 打造支持缩放平移的图片预览效果(上)
    bmob云代码中生成缩略图
    使用 OAuth2-Server-php 在 Yii 框架上搭建 OAuth2 Server
    Android 进阶 教你打造 Android 中的 IOC 框架 【ViewInject】 (下)
    数据库面试题
    Java三层架构
    group by&having&where
  • 原文地址:https://www.cnblogs.com/jiangnanrain/p/3271106.html
Copyright © 2011-2022 走看看