基于FPGA的图像缩小算法实现,包括tb测试文件和MATLAB辅助验证

目录

1.算法运行效果图预览

2.算法运行软件版本

3.部分核心程序

4.算法理论概述

5.算法完整程序工程


1.算法运行效果图预览

将FPGA的处理结果导出到matlab中显示图像效果:

2.算法运行软件版本

vivado2019.2

matlab2022a

3.部分核心程序

复制代码
`timescale 1ns / 1ps
//
// Company: 
// Engineer: 
// 
// Create Date: 2022/07/28 01:51:45
// Design Name: 
// Module Name: test_image
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//


module test_image;

reg i_clk;
reg i_rst;
reg i_en;
reg [7:0] image_buff [0:100000];
reg [7:0] II0;
wire [7:0] o_image;
wire flager;
integer fids,jj=0,dat;
 
//D:\FPGA_Proj\FPGAtest\codepz

initial 
begin
	fids = $fopen("D:\\FPGA_Proj\\FPGAtest\\codepz\\data.bmp","rb");
	dat  = $fread(image_buff,fids);
	$fclose(fids);
end
 
initial 
begin
i_clk=1;
i_rst=1;
#2000;
i_rst=0;
end 

always #10  i_clk=~i_clk;
 
always@(posedge i_clk) 
begin
     if(i_rst)
     begin
	 II0<=0;
	 jj<=0;
     end
     else
     begin
     if(jj<=66614 & jj>=1)
     i_en<=1'b1;
     else
     i_en<=1'b0;
	 II0<=image_buff[jj];
	 jj<=jj+1;
	 end
end
 
 
tops tops_u(
.i_clk              (i_clk),
.i_rst              (i_rst),
.i_en               (i_en),
.i_I0               (II0),
.o_image            (o_image),
.flager             (flager)
);

reg[19:0]cnts;
always @(posedge i_clk or posedge i_rst)
begin
     if(i_rst)
     begin
         cnts<=20'd0;
     end
else begin
         cnts<=cnts+20'd1;
     end
end  



integer fout1;
integer fout2;
initial begin
  fout1 = $fopen("flager.txt","w");
  fout2 = $fopen("expansion.txt","w");
end

 
always @ (posedge i_clk)
 begin
    if(cnts <= 66514)
    begin
	$fwrite(fout1,"%d\n",flager);
	$fwrite(fout2,"%d\n",o_image);
	end
	else
    begin
	$fwrite(fout1,"%d\n",0);
	$fwrite(fout2,"%d\n",0);
	end
	
end

endmodule
0X_014m

4.算法理论概述

图像放小算法主要通过抽取算法实现,常见的抽取算法最大值抽取,和均值抽取。其示意图如下所示:

以缩小一半为例,如果是最大值抽取,则在一个2*2窗口内,选择最大的像素输出,那么整个图像的维度就变为了原图像的一半。如果是均值抽取,则在一个2*2窗口内,选择四个像素均值输出,那么整个图像的维度就变为了原图像的一半。

在FPGA上实现图像放小算法时,可以采用硬件并行处理的方式,以提高处理速度。具体地,可以通过图像数据缓冲单元模块来实现。

5.算法完整程序工程

OOOOO

OOO

O

相关推荐
T.i.s2 小时前
基于MATLAB的ECG R峰自动检测与交互式校正系统
matlab·信号处理·心电图
IT猿手12 小时前
光伏模型参数估计:山羊优化算法(Goat Optimization Algorithm, GOA)求解光伏模型参数辨识问题,免费提供完整MATLAB代码链接
开发语言·算法·matlab·智能优化算法·光伏模型参数估计·光伏模型参数辨识·最新群智能算法
ALINX技术博客14 小时前
【黑金云课堂】FPGA技术教程Vitis开发:PS端UART与CAN通信
fpga开发·fpga
ytttr87316 小时前
惯性导航精解算程序(MATLAB实现)
开发语言·matlab
jghhh011 天前
认知无线电中基于能量检测的双门限频谱感知的 MATLAB 仿真
开发语言·matlab
BT-BOX1 天前
Matlab 2025B下载安装教程
开发语言·matlab
机器学习之心1 天前
多工况车速数据集训练LSTM-Attention用于车速预测,输出未来多个时间步车速,MATLAB代码
人工智能·matlab·lstm·lstm-attention·车速预测
FPGA小迷弟1 天前
FPGA工程师常见面试问题,有参考答案,必学!!!
fpga开发·面试·职场和发展·verilog·fpga·modelsim
Evand J1 天前
MATLAB绘图函数介绍:plotmatrix绘图,附MATLAB例子
开发语言·matlab·绘图
rit84324991 天前
基于遗传算法的电动汽车充电站选址优化:模型与MATLAB实现
开发语言·matlab