亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? create_new_image.m

?? 彩色圖像紋理提取的一種算法
?? M
字號:
function new_img = create_new_img(dist_matrix, objs, background, order, dist_vector)

% Create New Image, (Adam Meadows: ameadows@cs.ucr.edu)
% new_img = create_new_img(dist_matrix, objs, background, order, dist_vector)
% 
% DIST_MATRIX is a distance matrix formatted to pass to classicalmds()
% OBJS is a cell array containing the images for the individual objects
% BACKGROUND is the blank background image
% ORDER hold the order in which to place the objects (0 = choose randomly,
% 1 = left-right, 2 = right-left, 3 = top-down, 4 = bottom-up)
% DIST_VECTOR is an optional distance vector (OPTIONAL: if given, a dendogram is made)
%
% NEW_IMG returns the new, nicely formatted image
%


%use background as starter for new image
new_img = background;
dims = size(new_img);

%use MDS to find locations
loc =  dim_bound_mds(dims, dist_matrix);    

%how to sort the objects:
%left-right & up-down, left-right & down-up
%right-left & up-down, or right-left & down-up
if(order == 0)
    r = rand;
else
    r = order/4;
end

if r <= .25
    [S I] = sortrows(loc, [1]);
elseif r <= .50
    [S I] = sortrows(loc, [-1]);
elseif r <= .75
    [S I] = sortrows(loc, [2]);
else
    [S I] = sortrows(loc, [-2]);
end

%re-order objs
for i=1:length(objs) 
    objs2{i} = objs{I(i)};
end

%re-order locs
loc2 = loc(I,:);

for i=1 : length(objs2)
    
    %make sure objects aren't out of the picture frame
    objDims = size(objs2{i});
    
    dob = dist_out_of_bounds(loc2(i,:), objDims, dims);
    loc2(i,:) = loc2(i,:) - dob;
  
    
    %make sure there's no overlap
    loc2(i,:) = find_free_spot(loc2, objs2, dims, i);
    
    %reverse loc(i,:) to be valid for image
    loc_i = loc2(i,:);
    loc_i(2) = dims(1) - loc_i(2);

    %add the object to new_img
    l1 = ceil(loc_i(2)-objDims(1)+1);
    r1 = ceil(loc_i(2));
    l2 = ceil(loc_i(1));
    r2 = ceil(loc_i(1)+objDims(2)-1);
    
    %ensure that there are no 0s
    if l1 == 0 || r1 == 0 || l2 == 0 || r2 == 0
        l1 = l1+1;
        r1 = r1+1;
        l2 = l2+1;
        r2 = r2+1;
    end
    
    new_img(l1:r1,l2:r2,:) = objs2{i};
    
end %end of for each object

%imshow(new_img);

%if it was supplied, use dist_vector to create dendogram
if nargin == 5
    temp = [1:length(objs)];
    figure

    dist_vector = (dist_vector / max(dist_vector))*10;
    Z = linkage(dist_vector,'ward'); 
    [H, T,perm] = dendrogram(Z,0);
    hold on;
    set(gca,'Ylim',[-1.9 max(get(gca,'Ylim'))])

    for j = 1 : length(objs)
        i=perm(j); 
        i=temp(i);

        %Use object image passed in for display
        A = objs{i};
        image([0.6 1.4]+j-1,[-0.1 -0.8] , A)
    end;
    
    axis off
    axis equal
    orient landscape          

end %end of if dendogram

       
        
%end of create_new_image function

%==========================================================================
%==========================================================================
       
       
%function that creates an mds location matrix w/i dims of original image
function new_loc = dim_bound_mds(dims, dist_matrix)

%special case for if everything the same color/shape
if(dist_matrix == 0)
    loc = ones(length(dist_matrix), 2);
    loc(:,1) = loc(:,1) * dims(2)/2;
    loc(:,2) = loc(:,2) * dims(1)/2;
    new_loc = loc;
    return;
end

%loc = mdscale(dist_matrix,2);
loc = classicalmds(dist_matrix,2);
loc(:,1) = (loc(:,1) - min(loc(:,1)));
loc(:,1) = (loc(:,1) / max(loc(:,1)));
loc(:,1) = (loc(:,1) * dims(2));
loc(:,2) = (loc(:,2) - min(loc(:,2)));
loc(:,2) = (loc(:,2) / max(loc(:,2)));
loc(:,2) = (loc(:,2) * dims(1));

new_loc = loc;

% end of dim_bound_mds function

%==========================================================================
%==========================================================================

function varargout = imflipud(varargin)
%IMFLIPUD Flip an image upside down.
%
%   [Y, NEWMAP] = IMFLIPUD(X, MAP) flips the index image represented by the
%   index matrix X and the color map MAP in a up-down direction.  If MAP is
%   empty, X is assumed to be a bitmap, intensity image or RGB image.
%
%   NEWRGB = IMFLIPUD(RGB) flips the RGB represented by the 3-D image array
%   RGB in a up-down direction.
%
%   NEWI = IMFLIPUD(I) flips the intensity image represented by the 2-D
%   matrix I in a up-down direction.
%
%   NEWBM = IMFLIPUD(BM) flips the bitmap image represented by the logical
%   2-D matrix BW in a up-down direction.

%   Author:      Peter J. Acklam
%   Time-stamp:  2004-02-03 21:39:12 +0100
%   E-mail:      pjacklam@online.no
%   URL:         http://home.online.no/~pjacklam

   % Check number of input arguments.
   nargsin = nargin;
   error(nargchk(1, 2, nargsin));

   % Now do the actual flipping.
   varargout = varargin;
   varargout{1} = flipdim(x, 1);
   
%end of imflipud function

%==========================================================================
%==========================================================================

%Finds a new location for the ith object in objs, that doesn't overlap with
% any object < i
function loc_i = find_free_spot(loc, objs, dims, i)

set(0, 'RecursionLimit', 1000);

%first we see if it's valid
[valid moves] = valid_locs(loc, objs, i);

if(valid)
    loc_i = loc(i,:);
    return;
end %end of if point was valid

%now we know what the possible moves are try them all, smallest first

%next loc to recurse on
try_locs = {};
objDims = size(objs{i});

%try the smallest moves first
[S I] = sort(moves);
for k = 1:length(moves)
    %get new location
    m = moves(I(k));
    
    %what we do depends on I(k)
    if(I(k) == 1)
        loc_i = loc(i,:) + [0 m];
    elseif(I(k) == 2)
        loc_i = loc(i,:) + [0 -m];
    elseif(I(k) == 3)
        loc_i = loc(i,:) + [-m 0];
    else
        loc_i = loc(i,:) + [m 0];
    end
    
    %test new location
    dob = dist_out_of_bounds(loc_i, objDims, dims);
    if(dob == 0)
        try_locs{length(try_locs)+1} = loc_i;
        
        new_locs = loc;
        new_locs(i,:) = loc_i;
        if valid_locs(new_locs, objs, i)
            return;
        end
        
    end %end of if it was in bounds
    
end %end of loop through each move

%try up, down, left, right (in that order) make sure to check for
% out of bounds

%now recurse on a random direction and return result
tryme = ceil(rand() * length(try_locs));
new_locs = loc;
new_locs(i,:) = try_locs{tryme};
loc_i = find_free_spot(new_locs, objs, dims, i);

%end of find_free_spot function

%==========================================================================
%==========================================================================



%function to find out by how much A resides INSIDE B
% where A and B are arrays w/ values [ x_min x_max y_min y_max ]
% flag indicates whether A was in B or not, while moves holds how to move
% it to fix the overlap and is in the format: [up down left right]
% holding the distances loc has to move in each direction to escape the
% overlap (all values positive)
function [flag moves] = AinB(A, B)
    
AinB_x = 0;
AinB_y = 0;
flag = 0;
up = 0;
down = 0;
left = 0;
right = 0;

%if A's x values fall within B's
if((B(1) <= A(1)) && (A(1) <= B(2))) || ((B(1) <= A(2)) && (A(2) <= B(2)))
    left = A(2) - B(1) + 1;
    right = B(2) - A(1) + 1;
    AinB_x = 1;
end %end of if there's an x overlap

%if I's y values fall within J's
if((B(3) <= A(3)) && (A(3) <= B(4))) || ((B(3) <= A(4)) && (A(4) <= B(4)))
    up = B(4) - A(3) + 1;
    down = A(4) - B(3) + 1;
    AinB_y = 1;
end %end of if there's a y overlap

flag = 0;
if (AinB_x == 1) && (AinB_y == 1)
    flag = 1;
end

moves = [ up down left right ];

%end of AinB function

%==========================================================================
%==========================================================================


%function to check if current locations (up to i) are valid, returns
%flag == 1 if valid, 0 if invalid, moves = minimum distance to move
%[up down left right] to avoid all overlaps
function [flag moves] = valid_locs(loc, objs, i)

all_moves = [];
moves = [];
flag = 1;

%set the appropriate top/bottom values for i
objDims_i = size(objs{i});
xBottom_i = loc(i,1);
xTop_i = xBottom_i + objDims_i(2);
yBottom_i = loc(i,2);
yTop_i = yBottom_i + objDims_i(1);

%loop through all objects
for j = 1:i-1
    
    %set the appropriate top/bottom values for j
    objDims_j = size(objs{j});
    xBottom_j = loc(j,1);
    xTop_j = xBottom_j + objDims_j(2);
    yBottom_j = loc(j,2);
    yTop_j = yBottom_j + objDims_j(1);

    %if I falls within J
    I = [xBottom_i xTop_i yBottom_i yTop_i];
    J = [xBottom_j xTop_j yBottom_j yTop_j];
    
    [mflag, m] = AinB(I,J);
    if(mflag)
        flag = 0;
        all_moves = [all_moves; m];
    end
    
    [mflag, m] = AinB(J,I);
    if(mflag)
        flag = 0;
        %in this case we need to swap the moves, I needs to move
        m2 = [m(2) m(1) m(4) m(3)];
        all_moves = [all_moves; m2];
    end
    
end %end of for all previous objects
    
if(flag == 1)
    return;
end

%now calculate minimum moves in each direction
up = max(all_moves(:,1));
down = max(all_moves(:,2));
left = max(all_moves(:,3));
right = max(all_moves(:,4));
moves = [up down left right];

% end of valid_locs function

%==========================================================================
%==========================================================================

%Calculates how far out of bounds the given object is
function dob = dist_out_of_bounds(loc_i, objDims, dims)

dx = 0;
dy = 0;

%set the dx value
if(loc_i(1) < 1)
    dx = loc_i(1) - 1; %TBD: might have to -1 from this
elseif(loc_i(1) + objDims(2) >= dims(2))
    dx = loc_i(1) + objDims(2) - dims(2);
end %end of check on x value

%set the dy value
if(loc_i(2) < 1)
    dy = loc_i(2) - 1; %TBD: might have to -1 from this
elseif(loc_i(2) + objDims(1) >= dims(1))
    dy = loc_i(2) + objDims(1) - dims(1);
end %end of check on y value

dob = [ dx dy ];

%end of dist_out_of_bounds function 

%=========================================================================
%=========================================================================

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久精品国产免大香伊| 亚洲免费av网站| 日韩欧美一级二级三级| 欧美日韩激情在线| 在线视频一区二区三| 在线看国产一区| 精品视频一区二区三区免费| 欧美性色黄大片| 这里只有精品视频在线观看| 日韩欧美精品在线视频| 日韩精品一区国产麻豆| 久久青草欧美一区二区三区| 中文字幕不卡在线播放| 亚洲少妇中出一区| 一区二区三区免费看视频| 亚洲一区在线看| 日本va欧美va精品| 国产在线看一区| 成人午夜激情在线| 色婷婷久久99综合精品jk白丝| 色噜噜夜夜夜综合网| 这里只有精品免费| 久久蜜桃一区二区| 中文字幕亚洲欧美在线不卡| 亚洲综合视频在线观看| 日韩成人一级片| 国产精品资源在线| av不卡在线观看| 欧美日韩激情一区二区三区| 欧美变态tickle挠乳网站| 亚洲国产成人私人影院tom| 亚洲美女区一区| 日韩av中文在线观看| 精品午夜一区二区三区在线观看| 成人黄页毛片网站| 91国内精品野花午夜精品| 欧美一区二区三区免费视频| 久久综合久久99| 亚洲乱码日产精品bd| 蜜芽一区二区三区| 成人爽a毛片一区二区免费| 欧美午夜精品一区二区蜜桃| 精品精品欲导航| 亚洲青青青在线视频| 日韩欧美成人一区| 欧美日韩国产一级片| 欧美精品一区二区三区一线天视频 | 午夜精品久久久久久久蜜桃app| 麻豆成人91精品二区三区| av亚洲精华国产精华精| 884aa四虎影成人精品一区| 欧美高清在线一区二区| 天堂午夜影视日韩欧美一区二区| 国产成人在线免费观看| 欧美日韩在线观看一区二区| 欧美国产激情一区二区三区蜜月| 五月婷婷久久丁香| 成人综合婷婷国产精品久久免费| 555www色欧美视频| 中文字幕亚洲区| 激情五月婷婷综合| 欧美亚洲国产怡红院影院| 久久久综合精品| 日韩中文欧美在线| 91香蕉视频污| 久久久噜噜噜久久中文字幕色伊伊| 午夜视频一区在线观看| 99免费精品在线观看| 日韩视频一区二区在线观看| 一区二区三区在线免费播放| 成人免费视频caoporn| 欧美大片拔萝卜| 婷婷综合久久一区二区三区| av成人免费在线观看| 国产亚洲一区二区三区| 日本怡春院一区二区| 日本高清不卡aⅴ免费网站| 中文字幕乱码日本亚洲一区二区| 久久精品国产免费| 欧美日韩成人一区| 亚洲日本一区二区三区| 国产999精品久久| 久久综合九色综合久久久精品综合| 亚洲成国产人片在线观看| 91麻豆国产福利在线观看| 国产精品久久久久一区二区三区| 国产美女精品在线| 7777精品伊人久久久大香线蕉超级流畅 | 成人一级视频在线观看| 欧美成人a在线| 免费久久99精品国产| 欧美日本在线视频| 亚洲一区二区三区精品在线| 一本一道综合狠狠老| 亚洲视频一区二区免费在线观看| 成人小视频在线观看| 国产精品久久久一区麻豆最新章节| 国产激情精品久久久第一区二区 | 欧美精品一区二区三区在线| 久久国产麻豆精品| 国产精品一级片在线观看| 色悠久久久久综合欧美99| 自拍偷拍亚洲综合| 色综合天天狠狠| 亚洲精品成人天堂一二三| 91国偷自产一区二区三区观看 | 蜜臀国产一区二区三区在线播放| 欧美欧美欧美欧美首页| 午夜在线电影亚洲一区| 91麻豆精品国产91久久久久 | av爱爱亚洲一区| 亚洲男人电影天堂| 在线一区二区三区四区五区 | 成人污污视频在线观看| 国产精品不卡一区二区三区| 一本色道久久综合亚洲精品按摩| 一区二区三区中文字幕精品精品 | 亚洲三级电影网站| 日本韩国欧美一区| 亚洲国产成人91porn| 欧美另类z0zxhd电影| 蜜臀91精品一区二区三区| 久久一区二区三区四区| 成人av网站在线| 亚洲精品久久嫩草网站秘色| 欧美精选午夜久久久乱码6080| 免费一区二区视频| 久久精品一区四区| 99riav一区二区三区| 亚洲成人综合在线| 精品久久久三级丝袜| 不卡视频免费播放| 亚洲国产另类av| 日韩午夜在线观看视频| 国产高清一区日本| 亚洲精品国产精品乱码不99| 91精品国产综合久久精品性色| 国内精品不卡在线| 日韩一区在线播放| 91精品欧美综合在线观看最新| 精品一区二区三区免费播放| 一色桃子久久精品亚洲| 欧美日韩国产经典色站一区二区三区| 久久成人综合网| 亚洲天堂免费在线观看视频| 日韩一区二区免费在线观看| 高清在线不卡av| 亚洲高清一区二区三区| 国产亚洲污的网站| 欧美专区亚洲专区| 国产高清精品久久久久| 亚洲超碰精品一区二区| 国产日韩欧美不卡在线| 欧美日韩一级二级| 国产99精品视频| 免费美女久久99| 亚洲精品亚洲人成人网 | 精品一区二区免费| 亚洲男女毛片无遮挡| 欧美不卡一区二区| 欧美在线不卡视频| 国产精品一二三四| 香蕉乱码成人久久天堂爱免费| 日本一区二区三区视频视频| 欧美二区乱c少妇| 成人激情免费视频| 久久91精品久久久久久秒播| 亚洲三级电影全部在线观看高清| 欧美精品一区二区久久久| 一区二区三区资源| 久久青草欧美一区二区三区| 欧美日韩高清在线播放| 91香蕉视频在线| 国产98色在线|日韩| 久草在线在线精品观看| 亚洲韩国精品一区| 综合电影一区二区三区 | 精品欧美久久久| 欧美丝袜自拍制服另类| www.66久久| 久久99国产精品免费网站| 午夜不卡av在线| 一区二区三区四区精品在线视频| 日本一区二区动态图| 精品日产卡一卡二卡麻豆| 91麻豆精品国产自产在线| 欧美综合欧美视频| 91视频观看视频| 99视频有精品| 成人一区在线看| 国产成人综合在线播放| 国产精品自拍av| 国产剧情一区二区| 精品一区二区在线看| 久久精品国产999大香线蕉| 三级久久三级久久久| 亚洲国产精品久久人人爱| 一区二区在线观看免费| 一区二区三区在线看| 亚洲婷婷国产精品电影人久久|