-
大小: 5.9MB文件类型: .zip金币: 2下载: 0 次发布日期: 2023-09-23
- 语言: Matlab
- 标签: seamCarving matlab gui
资源简介
在matlab里面直接运行seamCarving_GUI.m就行,browse可以输入源图片,运行结果可以直接保存。

代码片段和文件信息
function [newImgnewImg2mask] = addSeam( img seam type img2 mask)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%addSeam function: duplicate given seam in the input image (img)
%Usage:
% newImg = addSeam( img seam‘v‘); %add vertical seam to the image
% newImg = addSeam( img seam‘v‘); %add horizontal seam to the image
% [newImgseamImg]=addSeam(imgseam‘v‘); %here you receive seamImg which
% contains the same image but with a colored (random color) seam on it.
% [newImgseamImg]=addSeam(image1seam‘v‘image2); %here you receive seamImg
% which contains image2 but with a colored (random color). Note: image2
% should have the same dimensions of image1.
%Input:
% -img: input image
% -seam: the interesting seam that is extracted from getSeams function
% -type: ‘H‘ for horizontal seams - ‘V‘ for vertical seams
% -img2: if you want to draw the new seam on another image
% (with the same dimensions of img object) use it. Otherwise you can
% use the same image object for both img and img2. (default img2=img).
% -mask: markup mask
%Output:
% -newImg: new image after adding the seam
% -newImg2: new image after adding noticable seam
% -mask: markup mask after adding new pixels
%Citation: Avidan Shai and Ariel Shamir. “Seam carving for content-aware
%image resizing. ACM Transactions on graphics (TOG). Vol. 26. No. 3.
%ACM 2007“
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Author: Mahmoud Afifi York University.
if nargin<3
error(‘Too few input arguments‘);
elseif nargin<4
img2=img;
mask=zeros(size(img1)size(img2));
elseif nargin<5
mask=zeros(size(img1)size(img2));
end
switch lower(type)
case ‘h‘
newSize=[size(img1)+1size(img2)]; %new size
T=0; %no transpose
case ‘v‘
%transpose img and seam
img_=zeros(size(img2)size(img1)size(img3)); %memory allocation
img_2=zeros(size(img22)size(img21)size(img23)); %memory allocation
for c=1:size(img3)
img_(::c)=img(::c)‘; %image transpose
img_2(::c)=img2(::c)‘; %image transpose
end
img=img_;
img2=img_2;
mask=mask‘;
clear img_ img_2; %delete temp obj
newSize=[size(img1)+1size(img2)]; %get new image‘s size
s_(1:2)=seam(1:1); %transpose seam as well
s_(1:1)=seam(1:2);
seam=s_;
clear s_; %delete temp object
T=1; %raise transpose flag
end
%convert indices to linear indices
linearInd=sub2ind([size(img1)size(img2)] seam(::1) seam(::2));
C=sort(cat(2[1:size(img1)*size(img2)]linearInd)); %doublicate seam indicies
newInd=zeros(size(linearInd)); %memory allocation
for i=1:length(linearInd)
ind=find(C==linearInd(i)); %get the location of interesting pixels in the new image
newInd(i)=ind(1); %take first
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 82587 2017-04-02 18:28 street_result.jpg
文件 1685 2017-04-03 02:40 test_code.m
文件 133909 2017-04-02 17:45 test1.jpg
文件 27905 2017-04-02 17:55 test1_result_result.jpg
文件 498054 2008-11-03 00:22 Van.bmp
文件 263054 2017-04-02 18:12 Van_result0.bmp
文件 89149 2017-04-02 18:35 van_seams.jpg
文件 139709 2017-04-02 15:51 york.jpg
文件 43346 2017-04-02 18:19 york_result4.jpg
文件 5032 2017-04-02 16:53 addSeam.m
文件 342 2017-04-02 15:16 addSeams.m
文件 7117 2017-04-02 15:06 createMap.m
文件 707 2017-04-01 14:28 getBestSeam.asv
文件 988 2017-04-02 16:50 getBestSeam.m
文件 702 2017-04-02 16:09 getGradient.m
文件 3267 2017-04-02 01:24 getSeams.m
文件 1179541 2017-04-19 14:16 logo.jpg
文件 564054 2008-11-03 00:21 Ocean.bmp
文件 240054 2017-04-02 18:20 ocean_result.bmp
文件 3252398 2017-04-19 14:06 ReadMe.pdf
文件 114 2017-04-02 18:08 Readme.txt
文件 2026 2017-04-02 10:43 removeSeam.asv
文件 2716 2017-04-02 17:17 removeSeam.m
文件 338 2017-04-02 14:18 removeSeams.m
文件 2334 2017-04-02 17:07 seamCarving.asv
文件 2334 2017-04-02 17:23 seamCarving.m
文件 30552 2017-04-02 16:03 seamCarving_GUI.fig
文件 10977 2017-04-19 14:18 seamCarving_GUI.m
文件 78704 2017-04-02 18:24 street.jpg
文件 1518 2017-04-19 02:24 license.txt
- 上一篇:图像超分辨率重建SRCNN算法
- 下一篇:Matlab特征提取代码
相关资源
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
- k近邻算法matlab实现
- matlab识别系统
评论
共有 条评论