• 大小: 16.73MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-03
  • 语言: Matlab
  • 标签: 图像形变  matlab  

资源简介

Rectangling Panoramic Images via Warping论文的MATLAB代码,处理图像,可以使得图像的边缘变为规则图形!! 懂得自然懂!!!

资源截图

代码片段和文件信息

#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

unsigned char* img;
int w h;
int* mask;
int* outMask;
unsigned char* outImg;
int* xDispMap;
int* yDispMap;
int* outXDispMap;
int* outYDispMap;

void readPPM(const char* name unsigned char** img int* w int* h) {
FILE* file = fopen(name “rb“);
fscanf(file “P6\n%d %d\n255\n“ w h);
int size = (*w) * (*h) * 3;
*img = new unsigned char[size];
fread(*img sizeof(unsigned char) size file);
fclose(file);
}
void writePPM(const char* name const unsigned char* img int w int h) {
FILE* file = fopen(name “wb“);
fprintf(file “P6\n%d %d\n255\n“ w h);
int size = w * h * 3;
fwrite(img sizeof(unsigned char) size file);
fclose(file);
}
void writePGM(const char* name const unsigned char* img int w int h) {
FILE* file = fopen(name “wb“);
fprintf(file “P5\n%d %d\n255\n“ w h);
int size = w * h;
fwrite(img sizeof(unsigned char) size file);
fclose(file);
}
void energy(const unsigned char* image int W int H int* energy int* mask){
memset(energy 0 sizeof(energy[0])*W*H);
//int addValue = max(WH)*3*10;
int addValue = 1000000;
#pragma omp parallel for
for(int i=0; i for(int j=0; j for(int k=0; k<3; ++k)
energy[i*W+j] += abs((int)image[(i*W+(j+1))*3+k] - (int)image[(i*W+j)*3+k]);
#pragma omp parallel for
for(int i=0; i for(int j=0; j for(int k=0; k<3; ++k)
energy[i*W+j] += abs((int)image[((i+1)*W+j)*3+k] - (int)image[(i*W+j)*3+k]);
#pragma omp parallel for
for(int i=0; i for(int j=0; j energy[i*W+j] += mask[i*W+j] * addValue;
}
///////////////////////Vertical Seam////////////////////////////
void accumulateVerEn(int * energy int W int H int* verticalEnergy int* verticalRoute){
/////////Initialize////////////
memset(verticalEnergy 0 sizeof(verticalEnergy[0])*W*H);
memset(verticalRoute 0 sizeof(verticalRoute[0])*W*H);
#pragma omp parallel for
for(int i=0; i verticalEnergy[i] = energy[i];

////////Accumulte the min energy and find the route//////////////
for(int i=1; i for(int j=0; j if(j-1<0){
verticalEnergy[i*W+j] = energy[i*W+j] + min(verticalEnergy[(i-1)*W+j] verticalEnergy[(i-1)*W+j+1]);//e(ij) + min( M(i-1j)  M(i-1 j+1))
verticalRoute[i*W+j] = (verticalEnergy[(i-1)*W+j]<=verticalEnergy[(i-1)*W+j+1]) ? 0 : 1;
}
else if(j+1>=W){
verticalEnergy[i*W+j] = energy[i*W+j] + min(verticalEnergy[(i-1)*W+j-1] verticalEnergy[(i-1)*W+j]);//e(ij) + min( M(i-1j-1)  M(i-1 j))
verticalRoute[i*W+j] = (verticalEnergy[(i-1)*W+j-1] }
else{
verticalEnergy[i*W+j] = energy[i*W+j] + min(min(verticalEnergy[(i-1)*W+j-1] verticalEnergy[(i-1)*W+j]) verticalEnergy[(i-1)*W+j+1]);//e(ij) + min( M(i-1j-1)  M(i-1 j) M(i-1 j+1))
verticalRoute[i*W+j] = (verticalEnergy[(i-1)*W+j-1]

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\
     目录           0  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\
     文件        7374  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\addSeam.cpp
     文件       11264  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\addSeam.mexw64
     文件         477  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\addSeam_wrap.m
     文件         449  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\checkInterSection.m
     文件         264  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\drawGrid.m
     文件         910  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\drawGridmask.m
     文件         374  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\findLB.m
     文件         385  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\findLS.m
     文件        1055  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\getLinTrans.m
     文件         253  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\getLinTrans2.m
     文件         195  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\getvertices.m
     文件       15825  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\globalmeshOpt.m
     文件        2090  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\localWarping.m
     文件       15605  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\main.m
     文件         548  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\mask_fg.m
     文件        1816  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\meshwarp.m
     文件        1248  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\quadexp.m
     文件         647  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\readme
     目录           0  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\reference code\
     文件       40960  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\reference code\lsd.mexw64
     文件       43520  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\reference code\lsd_image.mexw64
     文件     2520576  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\reference code\opencv_core247.dll
     文件     2363904  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\reference code\opencv_highgui247.dll
     文件     2203648  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\reference code\opencv_imgproc247.dll
     文件         894  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\runAll.m
     文件          57  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\showMask.m
     目录           0  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\sig13pano\
     文件      287042  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\sig13pano\10a_input.jpg
     文件      285372  2016-01-14 16:20  Rectangling-Panoramic-Images-Via-Warping-master\final code\sig13pano\10b_input.jpg
............此处省略13个文件信息

评论

共有 条评论