当前位置:网站首页>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 .
边栏推荐
- WPF 路由
- 流式细胞分析Flowjo 10介绍以及超详细图文安装激活教程
- 在商业智能BI开发过程中,什么问题的挑战性最大?
- 刷题笔记(十七)--二叉搜索树:关于属性问题
- GDB debugging skills (0) getting started with GDB
- WPF listbox virtualization
- [deeply understand tcapulusdb technology] table management of document acceptance
- WPF ListBox虚拟化
- GDB debugging practice (10) multi thread debugging
- About Eureka starting successfully but accessing 404
猜你喜欢

Uwp shadow effect

力扣刷题集结4(mysql版本)

实验二 栈和队列
![[deeply understand tcapulusdb technology] transaction execution of document acceptance](/img/7c/25a88f46e02cebd2e003b9590b9c13.png)
[deeply understand tcapulusdb technology] transaction execution of document acceptance

【深入理解TcaplusDB技术】一键安装Tmonitor后台

在商业智能BI开发过程中,什么问题的挑战性最大?
![class path resource [classpath*:mapper/*.xml] cannot be opened because it does not exist](/img/1a/294eb0128285686ede415991f69be7.png)
class path resource [classpath*:mapper/*.xml] cannot be opened because it does not exist

KVM虚拟机救援模式修改root密码 —— 筑梦之路

左手代码,右手开源,开源路上的一份子

An Chaoyun was selected as one of the "top ten cloud computing solution providers" in the Asia Pacific region by cioreview in 2022
随机推荐
大佬们, 2.2.1 的 StarRocks 主键模型的部分字段更新依旧不支持 sql 的方式是么?
Pycharm下可以正常运行,Pyinstaller打包软件报出Fatal error
左手代码,右手开源,开源路上的一份子
MySql踩坑记录
Wonderful review Figure 1 learn about Huawei cloud special dry goods
WPF 手写板
可乐与凉茶加速互卷
Technology sharing | introduction to kubernetes pod
WPF ComboBox设置选项与反显
利用while循环,分别计算1-100中奇数的和、偶数的和【方法一】
KVM虚拟机救援模式修改root密码 —— 筑梦之路
Pi4j pin analog bus, several ideas of control transmission and data transmission
window安装scoop的国内镜像
实验二 栈和队列
Use the while loop to calculate the odd and even sums in 1-100 [method 2]
WPF select Folder
[WUSTCTF2020]朴实无华-1
KVM虚拟机在线扩展磁盘 —— 筑梦之路
About Eureka starting successfully but accessing 404
Uwp tablet inkcanvas