FPGA图像处理(四)------ 图像裁剪

复制代码
`timescale 1ns / 1ps
//
// Description:  图像裁剪算法
//
module image_crop(
   input wire clk,
   input wire reset,
   
   input wire [10:0] img_width,
   input wire [10:0] img_height,
   input wire [10:0] img_x_start,
   input wire [10:0] img_x_end,
   input wire [10:0] img_y_start,
   input wire [10:0] img_y_end,
   
   input wire valid_i,
   input wire [23:0] img_data_i,
   
   output reg valid_o,
   output reg [23:0] img_data_o
   );

    //参数声明
    reg [10:0] x_cnt_r; //行计数器
    reg [10:0] y_cnt_r; //列计数器

    //计数
    always@(posedge clk or posedge reset) begin
        if(reset) begin
            x_cnt_r <= 'b0;
            y_cnt_r <= 'b0;
        end else begin
            x_cnt_r <= valid_i ? ((x_cnt_r == img_width - 1) ? 0 : x_cnt_r + 1) : x_cnt_r;
            y_cnt_r <= valid_i&&(x_cnt_r == img_width - 1) ? ((y_cnt_r == img_height - 1) ? 0 : y_cnt_r + 1) : y_cnt_r;
        end
    end    
    
    always@(posedge clk or posedge reset) begin
        if(reset) begin
            valid_o <= 'b0;
            img_data_o <= 'b0;
        end else begin
            valid_o <= valid_i&&(x_cnt_r >= img_x_start)&&(x_cnt_r < img_x_end)&&(y_cnt_r >= img_y_start)&&(y_cnt_r < img_y_end) ? 1'b1 : 1'b0;
            img_data_o <= img_data_i;
        end
    end
    
endmodule

相关推荐
Turing_kun2 小时前
基于FPGA的SPI控制FLASH读写
fpga开发
hahaha60169 小时前
差模干扰 & 共模干扰
fpga开发
璞致电子10 小时前
【PZ-KU060-KFB】——Kintex UltraScale 纯 FPGA 开发平台,释放高速并行计算潜能,高性价比的 FPGA 解决方案
fpga开发·fpga
go546315846512 小时前
基于深度学习的食管癌右喉返神经旁淋巴结预测系统研究
图像处理·人工智能·深度学习·神经网络·算法
我爱C编程13 小时前
基于FPGA的16QAM软解调+卷积编码Viterbi译码通信系统,包含帧同步,信道,误码统计,可设置SNR
fpga开发·16qam·软解调·帧同步·卷积编码·viterbi译码
南棱笑笑生14 小时前
20250726让荣品的PRO-RK3566开发板使用TF卡启动
fpga开发
Microvision维视智造14 小时前
从“人工眼”到‘智能眼’:EZ-Vision视觉系统如何重构生产线视觉检测精度?
图像处理·人工智能·重构·视觉检测
钟屿18 小时前
Multiscale Structure Guided Diffusion for Image Deblurring 论文阅读
论文阅读·图像处理·人工智能·深度学习·计算机视觉
仰望天空—永强19 小时前
PS 2025【七月最新v26.5】PS铺软件安装|最新版|附带安装文件|详细安装说明|附PS插件
开发语言·图像处理·python·图形渲染·photoshop
水果里面有苹果21 小时前
1-FPGA的LUT理解
fpga开发