实际比较filter2D和imfilter之间的关系
//filter2d的卷积方法
printf( "filter2d的卷积方法\n");
Mat srcMat(,,CV_32F);
Mat dstMat(,,CV_32F);
Mat srcH(,,CV_32F);
srcH.at<float>(,) = -;
srcH.at<float>(,) = -;
srcH.at<float>(,) = ;
srcH.at<float>(,) = ;
srcH.at<float>(,) = ;
srcH.at<float>(,) = ;
srcH.at<float>(,) = ;
srcH.at<float>(,) = ;
srcH.at<float>(,) = ;
printf( "卷积核\n");
for (int i=;i<srcH.rows;i++){
for (int j=;j<srcH.cols;j++){
printf("%f ",srcH.at<float>(i,j) );
}
printf("\n");
}
printf( "输入\n");
for (int i = ; i < ; i++){
for (int j = ; j < ; j++)
srcMat.at<float>(i,j) = i+;
}
for (int i = ; i < ; i++){
for (int j = ; j < ; j++){
printf("%.1f ",srcMat.at<float>(i,j));
}
printf("\n");
}
printf( "输出\n");
filter2D(srcMat,dstMat,srcMat.depth(),srcH);
printf("\n"); printf("\n");
for (int i = ; i < ; i++){
for (int j = ; j < ; j++){
printf("%.1f ",dstMat.at<float>(i,j));
}
printf("\n");
}
waitKey();
return ;
}


imwrite("gray.jpg",gray);
gray.convertTo(gray,CV_32F);
Mat dst;
filter2D(gray,dst,gray.depth(),srcH);
for (int i = ; i < gray.rows; i++){
for (int j = ; j < gray.cols; j++){
printf("%f ",dst.at<float>(i,j));
}
printf("\n");
}



#include <iostream>
#include <fstream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace std;
using namespace cv;
int _tmain(int argc, _TCHAR* argv[])
{
////filter2d的卷积方法
printf( "filter2d的卷积方法\n");
//Mat srcMat(10,10,CV_32F);
//Mat dstMat(10,10,CV_32F);
Mat srcH(,,CV_32F);
srcH.at<float>(,) = -;
srcH.at<float>(,) = -;
srcH.at<float>(,) = ;
srcH.at<float>(,) = ;
srcH.at<float>(,) = ;
srcH.at<float>(,) = ;
srcH.at<float>(,) = ;
srcH.at<float>(,) = ;
srcH.at<float>(,) = ;
printf( "卷积核\n");
for (int i=;i<srcH.rows;i++){
for (int j=;j<srcH.cols;j++){
printf("%f ",srcH.at<float>(i,j) );
}
printf("\n");
}
//读取图片的处理的方法
Mat gray = imread("test.jpg",);
imwrite("gray.jpg",gray);
gray.convertTo(gray,CV_32F);
gray = gray/; //归一化处理
fstream ftxt;
ftxt.open("src.txt",ios::out); //写入的方式,同时是append模式的就不会覆盖掉前面的东西了。
for (int i = ; i < gray.rows; i++){
for (int j = ; j < gray.cols; j++){
ftxt<<gray.at<float>(i,j)<<" ";
}
ftxt<<endl;
}
ftxt.close();
Mat dst;
filter2D(gray,dst,gray.depth(),srcH);
ftxt.open("rst.txt",ios::out); //写入的方式,同时是append模式的就不会覆盖掉前面的东西了。
for (int i = ; i < gray.rows; i++){
for (int j = ; j < gray.cols; j++){
ftxt<<dst.at<float>(i,j)<<" ";
}
ftxt<<endl;
}
ftxt.close();
imshow("dst",dst);
waitKey();
return ;
}

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace std;
using namespace cv; int _tmain(int argc, _TCHAR* argv[])
{
////filter2d的卷积方法
printf( "filter2d的卷积方法\n");
//Mat srcMat(10,10,CV_32F);
//Mat dstMat(10,10,CV_32F);
Mat srcH(3,3,CV_32F);
srcH.at<float>(0,0) = -2;
srcH.at<float>(0,1) = -1;
srcH.at<float>(0,2) = 4;
srcH.at<float>(1,0) = 3;
srcH.at<float>(1,1) = 3;
srcH.at<float>(1,2) = 3;
srcH.at<float>(2,0) = 3;
srcH.at<float>(2,1) = 2;
srcH.at<float>(2,2) = 1;
printf( "卷积核\n");
for (int i=0;i<srcH.rows;i++){
for (int j=0;j<srcH.cols;j++){
printf("%f ",srcH.at<float>(i,j) );
}
printf("\n");
}
//printf( "输入\n");
//for (int i = 0; i < 10; i++){
// for (int j = 0; j < 10; j++)
// srcMat.at<float>(i,j) = i+1;
//}
//for (int i = 0; i < 10; i++){
// for (int j = 0; j < 10; j++){
// printf("%.1f ",srcMat.at<float>(i,j));
// }
// printf("\n");
//}
//printf( "输出\n");
//filter2D(srcMat,dstMat,srcMat.depth(),srcH);
//printf("\n"); printf("\n");
//for (int i = 0; i < 10; i++){
// for (int j = 0; j < 10; j++){
// printf("%.1f ",dstMat.at<float>(i,j));
// }
// printf("\n");
//}
//读取图片的处理的方法
Mat gray = imread("test.jpg",0);
imwrite("gray.jpg",gray);
gray.convertTo(gray,CV_32F);
gray = gray/255; //归一化处理
fstream ftxt;
ftxt.open("src.txt",ios::out); //写入的方式,同时是append模式的就不会覆盖掉前面的东西了。
for (int i = 0; i < gray.rows; i++){
for (int j = 0; j < gray.cols; j++){
ftxt<<gray.at<float>(i,j)<<" ";
//printf("%.1f ",dst.at<float>(i,j));
}
ftxt<<endl;
//printf("\n");
}
ftxt.close();
Mat dst;
filter2D(gray,dst,gray.depth(),srcH); ftxt.open("rst.txt",ios::out); //写入的方式,同时是append模式的就不会覆盖掉前面的东西了。
for (int i = 0; i < gray.rows; i++){
for (int j = 0; j < gray.cols; j++){
ftxt<<dst.at<float>(i,j)<<" ";
//printf("%.1f ",dst.at<float>(i,j));
}
ftxt<<endl;
//printf("\n");
}
ftxt.close();
imshow("dst",dst); waitKey();
return 0;
}
p.s 转一篇有用博文,时间久了原始链接已经丢失,抱歉
1
2 3 4 5 6 7 8 |
clc;
clear; BW = im2bw( imread('imfilltest.tif')); imshow(BW); holes = imfill(BW, 'holes'); BW(~holes) = 1; |
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
#include
#include #include using namespace std; void my_imfillholes(Mat &src) void test_my_imfillholes() void main() |
1 1 1 0 0 0 0 0
1 1 1 0 1 1 0 0
1 1 1 0 1 1 0 0
1 1 1 0 1 1 1 0
1 1 1 0 1 1 1 0
1 1 1 0 1 1 1 0
1 1 1 0 0 1 1 0
1 1 1 0 0 0 0 0
0 0 0 0 0 0 0 0
0 1 1 0 1 1 0 0
0 1 1 0 1 1 0 0
0 1 1 0 1 1 1 0
0 1 1 0 1 1 1 0
0 1 1 0 1 1 1 0
0 1 1 0 0 1 1 0
0 0 0 0 0 0 0 0
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
#include
#include #include using namespace std; void my_imfillholes_v2() //setp 2: find the contour fill holes void main() |
实际比较filter2D和imfilter之间的关系的更多相关文章
- .NET Core与.NET Framework、Mono之间的关系
随着微软的.NET开源的推进,现在在.NET的实现上有了三个.NET Framework,Mono和.NET Core.经常被问起Mono的稳定性怎么样,后续Mono的前景如何,要回答这个问题就需要搞 ...
- .NET Core 和 .NET Framework 之间的关系
引用一段描述:Understanding the relationship between .NET Core and the .NET Framework. .NET Core and the .N ...
- 实体之间的关系【Entity Relationships】(EF基础系列篇9)
Here, you will learn how entity framework manages the relationships between entities. Entity framewo ...
- php CGI、Fastcgi、PHP-FPM的详细介绍与之间的关系
以下PHP CGI.Fastcgi.PHP-FPM的一些信息归纳和汇总----->详细介绍与之间的关系 一:CGI是干嘛的?CGI是为了保证web server传递过来的数据是标准格式的 web ...
- [转] valuestack,stackContext,ActionContext.之间的关系
三者之间的关系如下图所示: ActionContext 一次Action调用都会创建一个ActionContext 调用:ActionContext context = ActionContext ...
- angular源码阅读,依赖注入的原理:injector,provider,module之间的关系。
最开始使用angular的时候,总是觉得它的依赖注入方式非常神奇. 如果你跳槽的时候对新公司说,我曾经使用过angular,那他们肯定会问你angular的依赖注入原理是什么? 这篇博客其实是angu ...
- JavaScript和Java之间的关系
今天来简单而又详细地说说JavaScript和Java的关系. 开门见山总结性一句话,它们之间的关系 = 雷锋和雷峰塔之间的关系,换句话说:它们之间没什么关系. 但往往有不少初学者甚至中级者认为它们之 ...
- PHP类和对象之间的关系
类是对象的描述: 类和对象之间的关系类似于建房子的图纸和房子: 创建类--new对象--用对象: 一.对象的两个特性: --对象的行为(功能):可以对对象施加操作,例如,电视机的开.关.转换频道: - ...
- 关于计算机的ID和用户ID之间的关系
关于计算机的ID和用户ID之间的关系 计算机安装完系统后就会生成计算机ID,然后系统会以计算机ID为前缀附加数字创建Administrator(500)和Guest(501)用户ID,其他用户的ID将 ...
随机推荐
- KB奇遇记(5):奇葩的用人制度
8月份入职,公司不给我们正式任命,导致了我们开展工作困难重重,基本上很少有人会鸟你,做事仿佛名不正言不顺.哪怕你是未来信息部的老大也一样,网管们根本不买你的账.所以做ERP选型,做旧OA的选型以及加密 ...
- java系列笔记---正则表达式(1)常用符号
正则表达式---常用符号 首先声明,我这里列表的是经常使用的一些符号,如果你想得到全部,那建议你通过API中,搜索Pattern类,会得到所有符号. 字符类 [abc] a.b 或 c(简单类) [^ ...
- 使用VS Code从零开始开发调试.NET Core 1.1
使用VS Code 从零开始开发调试.NET Core 1.1.无需安装VS 2017 RC 即可开发.NET Core 1.1. .NET Core 1.1 发布也有一段时间了,最大的改动是从 pr ...
- redis安装-单机版
环境准备 因为redis使用c语言开发的,如果要运行在linux上,需要gcc-c++的环境.那么我们就要先看一下是否安装了gcc-c++如果没有的话,需要在虚拟机上安装gcc-c++环境(友情提示, ...
- java中字符串与数字的互相转换
import java.text.DecimalFormat; /* * String类中本身提供方法可以将几乎所有的基本类型转换为String类型 * sysout alt+/ 可以直接显示Syst ...
- java一维数组学习
/* * java学习: * 一维数组的使用: 声明语法 DataType[] name 或 DataType name[]. 初始化语法 DataType[] name = new DataType ...
- Easy单例模式
在学习单例模式前,不妨问自己几个问题:单例模式是怎么来的,单例模式怎么去用? 单例模式是怎么来的? 这就从设计模式起源开始,他是在实际实践中遇到类似情况可以通用经验所得到的总结,一般在其他模块或者方法 ...
- 张高兴的 UWP 开发笔记:用 Thumb 控件仿制一个可拖动 Button
在 WPF 上可用的控件拖动方法在 UWP 上大多没用,那干脆用 Thumb 仿制一个吧. 关于 Thumb 控件的教程也不多,毕竟在 WPF 控件拖动有很多种方法, Thumb 就显得很鸡肋了.下面 ...
- api接口json串换行
1.问题描述:在后台输入框中明明回车换行了,但是返回到 app客户端显示出来的 确实带有 \n 这个时候无论怎么调试都不行: 2.铺垫:大家都知道 php输出字符串的时候 使用 单引号 比使用 双 ...
- ArcGIS许可启动问题
前段时间,由于360常常删除重要文件终于发生在我身上.不得已换了电脑管家,清理后再次打开License Server Administrator时,发现启动项怎么也点不动了.而打开服务管理器,却发现A ...