当前位置:网站首页>Image processing 1:rgb888_ YCbCr444
Image processing 1:rgb888_ YCbCr444
2022-07-24 00:45:00 【Liu Yaner】
Preface
Text
One 、YCbCr
1.1 a key
- Calculation formula
- Assembly line
- Line signal beat

`timescale 1ns / 1ps
//
// Company:
// Engineer:
//
// Create Date: 2022/04/19 10:02:26
// Design Name:
// Module Name: RGB888_YCbCr444
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//
module RGB888_YCbCr444
(
//global clock
input clk, //cmos video pixel clock
input rst_n, //global reset
//Image data prepred to be processd
input per_frame_vsync, //Prepared Image data vsync valid signal
input per_frame_href, //Prepared Image data href vaild signal
input per_frame_clken, //Prepared Image data output/capture enable clock
input [7:0] per_img_red, //Prepared Image red data to be processed
input [7:0] per_img_green, //Prepared Image green data to be processed
input [7:0] per_img_blue, //Prepared Image blue data to be processed
//Image data has been processd
output post_frame_vsync, //Processed Image data vsync valid signal
output post_frame_href, //Processed Image data href vaild signal
output post_frame_clken, //Processed Image data output/capture enable clock
output [7:0] post_img_Y, //Processed Image brightness output
output [7:0] post_img_Cb, //Processed Image blue shading output
output [7:0] post_img_Cr //Processed Image red shading output
);
//--------------------------------------------
/********************************************* //Refer to <OV7725 Camera Module Software Applicaton Note> page 5 Y = (77 *R + 150*G + 29 *B)>>8 Cb = (-43*R - 85 *G + 128*B)>>8 + 128 Cr = (128*R - 107*G - 21 *B)>>8 + 128 Y = (77 *R + 150*G + 29 *B)>>8 Cb = (-43*R - 85 *G + 128*B + 32768)>>8 Cr = (128*R - 107*G - 21 *B + 32768)>>8 **********************************************/
//Step 1
reg [15:0] img_red_r0, img_red_r1, img_red_r2;
reg [15:0] img_green_r0, img_green_r1, img_green_r2;
reg [15:0] img_blue_r0, img_blue_r1, img_blue_r2;
// First stage assembly line : Perform multiplication
[email protected](posedge clk or negedge rst_n)begin
if(!rst_n)
begin
img_red_r0 <= 0;
img_red_r1 <= 0;
img_red_r2 <= 0;
img_green_r0 <= 0;
img_green_r1 <= 0;
img_green_r2 <= 0;
img_blue_r0 <= 0;
img_blue_r1 <= 0;
img_blue_r2 <= 0;
end
else
begin
img_red_r0 <= per_img_red * 8'd77;
img_red_r1 <= per_img_red * 8'd43;
img_red_r2 <= per_img_red * 8'd128;
img_green_r0 <= per_img_green * 8'd150;
img_green_r1 <= per_img_green * 8'd85;
img_green_r2 <= per_img_green * 8'd107;
img_blue_r0 <= per_img_blue * 8'd29;
img_blue_r1 <= per_img_blue * 8'd128;
img_blue_r2 <= per_img_blue * 8'd21;
end
end
//--------------------------------------------------
//Step 2
reg [15:0] img_Y_r0;
reg [15:0] img_Cb_r0;
reg [15:0] img_Cr_r0;
// Second stage assembly line : Perform addition
[email protected](posedge clk or negedge rst_n)begin
if(!rst_n)
begin
img_Y_r0 <= 0;
img_Cb_r0 <= 0;
img_Cr_r0 <= 0;
end
else
begin
img_Y_r0 <= img_red_r0 + img_green_r0 + img_blue_r0;
img_Cb_r0 <= img_blue_r1 - img_red_r1 - img_green_r1 + 16'd32768;
img_Cr_r0 <= img_red_r2 + img_green_r2 + img_blue_r2 + 16'd32768;
end
end
//--------------------------------------------------
//Step 3
reg [7:0] img_Y_r1;
reg [7:0] img_Cb_r1;
reg [7:0] img_Cr_r1;
// The third stage pipeline : Move right 8 position = Divide 256 ??????
[email protected](posedge clk or negedge rst_n)begin
if(!rst_n)
begin
img_Y_r1 <= 0;
img_Cb_r1 <= 0;
img_Cr_r1 <= 0;
end
else
begin
img_Y_r1 <= img_Y_r0[15:8];
img_Cb_r1 <= img_Cb_r0[15:8];
img_Cr_r1 <= img_Cr_r0[15:8];
end
end
//------------------------------------------
//lag 3 clocks signal sync
// It has 3 Class assembly line , So I experienced 3 A clock , So you need to put the input line 、 Enable signal, etc 3 Second beat operation
// The beating operation here is quite powerful , Worth learning !!
//---------------------------------------------
reg [2:0] per_frame_vsync_r;
reg [2:0] per_frame_href_r;
reg [2:0] per_frame_clken_r;
[email protected](posedge clk or negedge rst_n)begin
if(!rst_n)
begin
per_frame_vsync_r <= 0;
per_frame_href_r <= 0;
per_frame_clken_r <= 0;
end
else
begin
per_frame_vsync_r <= {
per_frame_vsync_r[1:0], per_frame_vsync};
per_frame_href_r <= {
per_frame_href_r [1:0], per_frame_href};
per_frame_clken_r <= {
per_frame_clken_r[1:0], per_frame_clken};
end
end
assign post_frame_vsync = per_frame_vsync_r[2];
assign post_frame_href = per_frame_href_r [2];
assign post_frame_clken = per_frame_clken_r[2];
// When there is a line signal , It outputs
assign post_img_Y = post_frame_href ? img_Y_r1 : 8'd0;
assign post_img_Cb = post_frame_href ? img_Cb_r1: 8'd0;
assign post_img_Cr = post_frame_href ? img_Cr_r1: 8'd0;
endmodule
边栏推荐
- 如何提升数据质量
- Problem note - unable to open include file: "direct.h": no such file or directory
- 網絡系統實驗:ping不通的問題解决
- Gbase 8C system table information function (II)
- MySQL client to server character set conversion
- Gbase 8C access authority query function (V)
- 《天幕红尘》笔记与思考(六)因缺而需
- The high-quality digital collection of guochuang's "children's song line" is on sale, and you are invited to create a young martial arts Jianghu dream
- GBase 8c 字符串操作符
- Detailed overview of data standards -2022
猜你喜欢

Creo 9.0 mouse button operation for model observation

测试小码农也有大目标,最新BAT大厂面试题大总结(持续更新中...)

Development of main applet for business card traffic near the map
CA digital certificate

Network system experiment: solve the problem of Ping failure

PHP implements stripe subscription

数仓数据指标和标签体系区别

Redis | very important Middleware
![[the 83rd fortnight of leetcode]](/img/41/411dc235a34f9dde06a41323628648.png)
[the 83rd fortnight of leetcode]

Simple implementation and analysis of binary search tree
随机推荐
Redis data structure
Classic examples of C language switch case statement conversion date format
JS drag and drop element
通信模块整理(二)HC-05
Gbase 8C session information function (6)
Don't let Fujin Yibo see this
Gbase 8C access authority access function (IV)
High number_ Chapter 1 space analytic geometry and vector algebra__ Two point distance
Understanding polymorphism and letting different "people" do the same thing will produce different results
Development of main applet for business card traffic near the map
AWS Part 4 one machine and one secret
Introduction to several scenarios involving programming operation of Excel in SAP implementation project
Selection method of geometric objects in Creo 9.0
Sed in-depth understanding and use
Method of C language annotation
MySQL common commands
Classic examples of C language - adding two scores
Reverse linked list drawing demonstration
数据模型设计方法概述
Redis persistence mechanism RDB, AOF