-
大小: 5.9MB文件类型: .zip金币: 1下载: 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特征提取代码
相关资源
- Matlab特征提取代码
- 图像超分辨率重建SRCNN算法
- Chan-Vese算法的MATLAB代码
- 数字信号处理课程设计语音信号的采
- 基于haar特征+AdaBoost,CascadeBoost算法的
- 基于MATLAB的车牌识别54493
- MATLAB有限元分析与应用.pdf
- LTE仿真程序
- DQPSK 调制解调器的MATLAB实现
- matlab游戏
-
matlab之simuli
nk最通俗教程 -
Matlab_Simuli
nk与控制系统仿真 PDF - 现代通信系统_使用MATLAB (刘树棠译)
- 雷达系统分析与设计应用 MATLAB
-
详解MATLABSimuli
nk通信系统建模与仿真 - MPC_MATLAB_Book.pdf
- 数字信号处理实验报告内含matlab源代
- 阵列信号处理算法MATLAB常用程序
- 先进PID控制MATLAB仿真第3版完整仿真程
- PID控制MATLAB仿真第2版含MATLAB源代码
- bp神经网络 matlab代码 识别0到10的数字
- MATLAB教程详细讲解
- 全景图像拼接代码MATLAB版本
- MATLAB 程序 实现图像拼接,自动匹配特
- surf的matlab算法实现
- 忆阻器 Matlab 源代码 附带用户手册
- MATLAB神经网络应用设计
- 多份OFDM仿真的MATLAB仿真代码,以及相
- MATLAB智能算法-温正-配书代码
- 多机器人路径规划-matlab
评论
共有 条评论