From: <car...@us...> - 2012-05-15 12:52:09
|
Revision: 10441 http://octave.svn.sourceforge.net/octave/?rev=10441&view=rev Author: carandraug Date: 2012-05-15 12:51:58 +0000 (Tue, 15 May 2012) Log Message: ----------- imcrop: new function for image package. Submitted to mailing list by Pablo Rossi <pr...@in...> Modified Paths: -------------- trunk/octave-forge/main/image/INDEX trunk/octave-forge/main/image/NEWS Added Paths: ----------- trunk/octave-forge/main/image/inst/imcrop.m Modified: trunk/octave-forge/main/image/INDEX =================================================================== --- trunk/octave-forge/main/image/INDEX 2012-05-15 06:42:56 UTC (rev 10440) +++ trunk/octave-forge/main/image/INDEX 2012-05-15 12:51:58 UTC (rev 10441) @@ -95,6 +95,7 @@ poly2mask roicolor Spatial transformations + imcrop impad imperspectivewarp imremap Modified: trunk/octave-forge/main/image/NEWS =================================================================== --- trunk/octave-forge/main/image/NEWS 2012-05-15 06:42:56 UTC (rev 10440) +++ trunk/octave-forge/main/image/NEWS 2012-05-15 12:51:58 UTC (rev 10441) @@ -11,6 +11,7 @@ imabsdiff imadd imbothat + imcrop imdivide imlincomb immultiply Added: trunk/octave-forge/main/image/inst/imcrop.m =================================================================== --- trunk/octave-forge/main/image/inst/imcrop.m (rev 0) +++ trunk/octave-forge/main/image/inst/imcrop.m 2012-05-15 12:51:58 UTC (rev 10441) @@ -0,0 +1,63 @@ +## Copyright (C) 2012 Pablo Rossi <pr...@in...> +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 3 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} @var{col} = imcrop (@var{Img}) +## Crop image. +## +## Displays the image @var{Img} in a figure window and creates a +## cropping tool associated with that image. Pick: first the top left +## corner, second bottom right. The cropped image returned, @var{col}. +## @end deftypefn + +## Author: Pablo Rossi <pr...@in...> +## Date: 13 March 2012 + +function col = imcrop (Img) + + imshow(Img); + [a,b]=size(Img); + [hl,rd]=ginput; + + if hl(1)<=1; hl(1)=1; endif + + if rd(1)<=1; rd(1)=1; endif + + if hl(2)>=b; hl(2)=b; endif + + if rd(2)>=a; rd(2)=a; endif + + while hl(1) > hl(2) || rd(1) > rd(2) + + display ("Pick: first the top left corner, second bottom right","Error Procedure"); + + [hl,rd]=ginput; + + if hl(1)<=1; hl(1)=1; endif + + if rd(1)<=1; rd(1)=1; endif + + if hl(2)>=b; hl(2)=b; endif + + if rd(2)>=a; rd(2)=a; endif + + endwhile + + hl=floor(hl); + rd=floor(rd); + col=[]; + col=Img(rd(1):rd(2),hl(1):hl(2)); + +endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |