当前位置:网站首页>[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 ).
边栏推荐
- Generate random 6-bit invitation code in PHP
- 【Random Erasing】《Random Erasing Data Augmentation》
- 传统目标检测笔记1__ Viola Jones
- 【Mixup】《Mixup:Beyond Empirical Risk Minimization》
- ABM thesis translation
- [in depth learning series (8)]: principles of transform and actual combat
- 【MobileNet V3】《Searching for MobileNetV3》
- 深度学习分类优化实战
- Faster-ILOD、maskrcnn_benchmark训练coco数据集及问题汇总
- EKLAVYA -- 利用神经网络推断二进制文件中函数的参数
猜你喜欢

【BiSeNet】《BiSeNet:Bilateral Segmentation Network for Real-time Semantic Segmentation》

【MagNet】《Progressive Semantic Segmentation》

【Mixup】《Mixup:Beyond Empirical Risk Minimization》

Faster-ILOD、maskrcnn_benchmark训练coco数据集及问题汇总

【Mixed Pooling】《Mixed Pooling for Convolutional Neural Networks》

联邦学习下的数据逆向攻击 -- GradInversion

【DIoU】《Distance-IoU Loss:Faster and Better Learning for Bounding Box Regression》

常见CNN网络创新点

【MnasNet】《MnasNet:Platform-Aware Neural Architecture Search for Mobile》

Faster-ILOD、maskrcnn_ Benchmark training coco data set and problem summary
随机推荐
open3d学习笔记五【RGBD融合】
常见的机器学习相关评价指标
Two dimensional array de duplication in PHP
用MLP代替掉Self-Attention
传统目标检测笔记1__ Viola Jones
Solve the problem of latex picture floating
【MobileNet V3】《Searching for MobileNetV3》
How to clean up logs on notebook computers to improve the response speed of web pages
Implementation of yolov5 single image detection based on onnxruntime
Pointnet understanding (step 4 of pointnet Implementation)
TimeCLR: A self-supervised contrastive learning framework for univariate time series representation
[binocular vision] binocular correction
程序的执行
MoCO ——Momentum Contrast for Unsupervised Visual Representation Learning
yolov3训练自己的数据集(MMDetection)
【Sparse-to-Dense】《Sparse-to-Dense:Depth Prediction from Sparse Depth Samples and a Single Image》
Proof and understanding of pointnet principle
程序的内存模型
半监督之mixmatch
ABM论文翻译