?? show.m
字號(hào):
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
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -