⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 show.m

📁 Using the idea from Seam Carving for Content-Aware Image Resizing, the codes enables a selected im
💻 M
字号:
function show(I,M)%show - show content aware image resizing%% show(I,M) opens a figure window to allow interactive resizing of I% in one direction based on the seam removal map M.%% determine whether seams are horizontal or vertical[h,w] = size(M);horiz = all(sum(M,1)==sum(1:h));vert = all(sum(M,2)==sum(1:w));%if ~xor(horiz,vert), error('seams not horizontal or vertical?!'); end%% set up figurefh = figure;set(fh,'DoubleBuffer','on');set(fh,'WindowButtonDownFcn',@mouseDown);set(fh,'WindowButtonMotionFcn',@mouseMove);set(fh,'WindowButtonUpFcn',@mouseUp);set(fh,'WindowScrollWheelFcn',@mouseWheel);% set(fh,'Interruptible','off');% set(fh,'BusyAction','queue');% ensure figure is large enough for 200% resizingif horiz,    ih = imshow(cat(1,I,I));    title('horizontal seams');else    ih = imshow(cat(2,I,I));    title('vertical seams');end% show the initial imageset(ih,'CData',I);%% resizingn = 0; % how many seams we are removing total% pre-transpose data if we have vertial seamsif vert,    I = permute(I,[2,1,3]);    M = M';end    function move(dn)        % remove (or add) an additional dn seams        n = n + dn;        J = retarget(I,M,n);        if vert, J = permute(J,[2,1,3]); end        set(ih,'CData',J);        drawnow;    end%% mouse callbacksp0 = []; % location of mouse down eventdrag = false; % is the mouse being dragged?resizing = false; % are we resizing the image?    function mouseDown(src,evt)        p0 = get(fh,'CurrentPoint');        drag = true;    end    function mouseMove(src,evt)        if ~drag, return; end        if resizing, return; end % serialize execution of this function        resizing = true;        p = get(fh,'CurrentPoint');        if horiz,            move( p(2) - p0(2) );        else            move( p0(1) - p(1) );        end        p0 = p;        resizing = false;    end    function mouseWheel(src,evt)        move( -evt.VerticalScrollCount * evt.VerticalScrollAmount );    end    function mouseUp(src,evt)        drag = false;    endend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -