当前位置:网站首页>An error prone to appear when MATLAB is doing image processing: to improve the operation speed, use the pre declared zero matrix to store image data
An error prone to appear when MATLAB is doing image processing: to improve the operation speed, use the pre declared zero matrix to store image data
2022-06-21 22:36:00 【Jida qinshaoyou】
MATLAB A mistake that is easy to appear in image processing : In order to improve the operation speed, a pre declared zero matrix is used to store image data .
This misunderstanding is very hidden , Because such a pre declared zero matrix can significantly improve the operation speed , So they often think it is the right way . But to ensure that the image data looks normal , It is often necessary to use im2double Function to convert the input image data into double Type of matrix , such imshow The resulting image looks normal , In fact, the accuracy of image data has changed due to format conversion , It is easy to report errors when processing data .
as follows : The code in the annotation section is easy to cause changes in the image data .
src_img = strcat(img_path, img_name);
pure_name = size(img_name,2);
pic_odd_name = strcat(img_name(1:pure_name-4), '_odd.bmp');
pic_even_name = strcat(img_name(1:pure_name-4), '_even.bmp');
pic = imread(src_img);
% pic = im2double(pic);
[pic_height, pic_width, rgb_depth] = size(pic);
% pic_odd = zeros([pic_height, pic_width/2, rgb_depth]);
% pic_even = zeros([pic_height, pic_width/2, rgb_depth]);
for i = 1:1:pic_height
for j = 1:1:pic_width
% for k = 1:1:rgb_depth
if(mod(j,2) == 1) % even pixel
pic_even(i,(j+1)/2,:) = pic(i,j,:);
else
pic_odd(i,j/2,:) = pic(i,j,:);
end
% end
end
end
therefore , It can be handled directly , No need to declare the size of storage space in advance , Slow is slow . Another method is to observe the type of image data after the image data is read into the work area , Then declare the same type of zero matrix , This approach is also feasible in theory , Compared to not declaring storage space , It can be much faster when processing a large number of images .
边栏推荐
- Correspondence between rtx3090 and pytorch versions
- LeetCode-543-二叉树的直径
- 牛客月赛-环上食虫
- Use the do while loop to calculate the odd and even sums in 1-100 [method 1]
- Anaconda add channels
- promise错误捕获处理——Promisifying技术
- High level project - project initiation management
- WPF 数据绑定:数据源Source-目标Target
- UEFI dual system + dual hard disk installation
- 【深入理解TcaplusDB技術】TcaplusDB構造數據
猜你喜欢
![[leetcode] 8. String conversion integer (ATOI)](/img/e8/08986237d8945685888817f214d7a9.png)
[leetcode] 8. String conversion integer (ATOI)

Introduction to software architecture

promise错误捕获处理——Promisifying技术

nuxt ssr打包和部署

Electronic bidding procurement mall system: optimize traditional procurement business and speed up enterprise digital upgrading

Second understanding microservice

UEFI dual system + dual hard disk installation
![[deeply understand tcapulusdb technology] tmonitor background one click installation](/img/f6/d2a287aac4ef3dfa8c75f7130202a4.png)
[deeply understand tcapulusdb technology] tmonitor background one click installation

专业字体设计编辑Glyphs 3

Matlab2020a使用App Designer如何导出exe
随机推荐
WPF thread manipulation UI problem
flutter系列之:flutter中的IndexedStack
Uwp confirms whether there is pop-up display
GDB debugging skills (0) getting started with GDB
联系五心红娘脱单
力扣刷题集结4(mysql版本)
利用do while循环,分别计算1-100中奇数的和、偶数的和【方法一】
C# DataTable转换为Entity(反射&&泛型)
STM32F407程序移植到STM32F429
WPF 线程操纵UI问题
WPF tablet
tkinter中text文本与scroll滚动条关联
必读书籍
Jeu de boutons de force 4 (version MySQL)
WPF ComboBox设置选项与反显
更好的管理各种音乐,专业的DJ音乐管理软件Pioneer DJ rekordbox
Qt滚动区域QScrollArea
Electronic bidding procurement mall system: optimize traditional procurement business and speed up enterprise digital upgrading
vb屏幕分辨率设置和获取_hawkol_新浪博客
【深入理解TcaplusDB技术】单据受理之事务执行