当前位置:网站首页>[learning notes] matlab self compiled image convolution function
[learning notes] matlab self compiled image convolution function
2022-07-02 07:52:00 【Silent clouds】
Image convolution principle
Code
% Convolution function
%made by yao
function result = myconv(kernel,img)
[k,num] = size(kernel);
% Determine whether the passed in array is double precision floating-point , Otherwise, type conversion
if ~isa(img,'double')
p1 = double(img);
else
p1 = img;
end
% Extract dimensions
[m,n] = size(p1);
% Construct the template after convolution
% Here we consider the problem of edges , So the black edge was cut off
result = zeros(m-k+1,n-k+1);
for i = ((k-1)/2+1):(m-(k-1)/2)
for j = ((k-1)/2+1):(n-(k-1)/2)
result(i-(k-1)/2,j-(k-1)/2) = sum(sum(kernel .* p1(i-(k-1)/2:i+(k-1)/2,j-(k-1)/2:j+(k-1)/2)));
end
end
end
Here's an example , For example, we have 3x3 Convolution kernel , Convolute the image , So in (1,1) When , It will be associated with the outside of the image edge ( Including the upper row and the left column , Similarly, the same situation will appear at the bottom and right of the image ).
So to avoid this , Will the 3x3 The starting point of convolution is set at (2,2) It's about . If the image has m Column n That's ok , Then the convolution of one line terminates in n-1 Out , The convolution end point of a column is m-1 It's about .
Empathy ,5x5 And longer convolution kernels are the same operation .
5x5 The convolution kernel of starts at (3,3), Termination point (m-2,n-2).
So for odd convolution kernels , Let the length of convolution kernel be k, Then the initial convolution point is ((k-1)/2+1), Termination point (m-(k-1)/2)( The ranks are the same , Just change it ).
边栏推荐
- Convert timestamp into milliseconds and format time in PHP
- PointNet原理证明与理解
- 使用百度网盘上传数据到服务器上
- 半监督之mixmatch
- 【C#笔记】winform中保存DataGridView中的数据为Excel和CSV
- Remplacer l'auto - attention par MLP
- 【雙目視覺】雙目矯正
- What if the laptop task manager is gray and unavailable
- 【Programming】
- Deep learning classification Optimization Practice
猜你喜欢
【Random Erasing】《Random Erasing Data Augmentation》
【Batch】learning notes
How to clean up logs on notebook computers to improve the response speed of web pages
【学习笔记】Matlab自编图像卷积函数
open3d学习笔记五【RGBD融合】
【FastDepth】《FastDepth:Fast Monocular Depth Estimation on Embedded Systems》
【Hide-and-Seek】《Hide-and-Seek: A Data Augmentation Technique for Weakly-Supervised Localization xxx》
Faster-ILOD、maskrcnn_benchmark安装过程及遇到问题
程序的执行
常见CNN网络创新点
随机推荐
Faster-ILOD、maskrcnn_ Benchmark installation process and problems encountered
Remplacer l'auto - attention par MLP
【Wing Loss】《Wing Loss for Robust Facial Landmark Localisation with Convolutional Neural Networks》
Yolov3 trains its own data set (mmdetection)
【Sparse-to-Dense】《Sparse-to-Dense:Depth Prediction from Sparse Depth Samples and a Single Image》
What if the laptop task manager is gray and unavailable
【C#笔记】winform中保存DataGridView中的数据为Excel和CSV
【学习笔记】反向误差传播之数值微分
【AutoAugment】《AutoAugment:Learning Augmentation Policies from Data》
Network metering - transport layer
自然辩证辨析题整理
MoCO ——Momentum Contrast for Unsupervised Visual Representation Learning
ModuleNotFoundError: No module named ‘pytest‘
Machine learning theory learning: perceptron
mmdetection训练自己的数据集--CVAT标注文件导出coco格式及相关操作
EKLAVYA -- 利用神经网络推断二进制文件中函数的参数
【Cutout】《Improved Regularization of Convolutional Neural Networks with Cutout》
PPT的技巧
TimeCLR: A self-supervised contrastive learning framework for univariate time series representation
What if the laptop can't search the wireless network signal