FPGA实现图像处理之【直方图均衡-寄存器版】

FPGA实现直方图统计

一、图像直方图统计原理

直方图的全称为灰度直方图,是对图像每一灰度间隔内像素个数的统计。即对一张图片中每隔二灰度值的像素数量做统计,然后以直方图的形式展现出来。图下的亮暗分布在直方图中就可以一目了然,直方图在图像前端和后端处理中都有广泛的应用,比如图像的直方图均衡、图像自动曝光控制和图像特征提取等。

image-20240428214846205

二、基于寄存器(逻辑资源)的直方图统计系统框图

图片大小640x480,需要20bit的位宽来计像素的个数。i_img_vld为高时,输入图片数据i_img_data[7:0]有效,“256级灰度灰度值的像素计数”模块统计0~255中灰度级数的个数,“输入有效像素个数计数”模块用于计算i_mg_data已经输入了几个,“256级直方图统计结果分时输出”模块是输入256个灰度级的统计结果,需要256个时钟周期,每个周期输出一级灰度级的结果。

image-20240428220751855

三、代码实现

这个代码简单而且暴力,主要是易于理解,占用较多的逻辑资源。因为这种统计方法,对于i_image_data来说有256个扇出,所以系统时钟频率不会跑的很高,时序很难收敛


`timescale 1ns/1psmodule m_histogram_reg#(parameter P_IMAGE_WIDTH=640,parameter P_IMAGE_HIGHT=480)(input i_clk,input i_rst_n,input i_image_vld,input [7:0] i_image_data,output reg o_result_rdy,output reg [19:0] o_result_data);localparam P_IMAGE_SIZE = P_IMAGE_HIGHT*P_IMAGE_WIDTH;
reg [19:0] r_hist_cnt[255:0];//每个灰度值统计的计数器//256个灰度值的直方图统计
always@(posedge i_clk)beginif(!i_rst_n)beginr_hist_cnt[0] <= 20'd0;r_hist_cnt[1] <= 20'd0;r_hist_cnt[2] <= 20'd0;r_hist_cnt[3] <= 20'd0;r_hist_cnt[4] <= 20'd0;r_hist_cnt[5] <= 20'd0;r_hist_cnt[6] <= 20'd0;r_hist_cnt[7] <= 20'd0;r_hist_cnt[8] <= 20'd0;r_hist_cnt[9] <= 20'd0;r_hist_cnt[10] <= 20'd0;r_hist_cnt[11] <= 20'd0;r_hist_cnt[12] <= 20'd0;r_hist_cnt[13] <= 20'd0;r_hist_cnt[14] <= 20'd0;r_hist_cnt[15] <= 20'd0;r_hist_cnt[16] <= 20'd0;r_hist_cnt[17] <= 20'd0;r_hist_cnt[18] <= 20'd0;r_hist_cnt[19] <= 20'd0;r_hist_cnt[20] <= 20'd0;r_hist_cnt[21] <= 20'd0;r_hist_cnt[22] <= 20'd0;r_hist_cnt[23] <= 20'd0;r_hist_cnt[24] <= 20'd0;r_hist_cnt[25] <= 20'd0;r_hist_cnt[26] <= 20'd0;r_hist_cnt[27] <= 20'd0;r_hist_cnt[28] <= 20'd0;r_hist_cnt[29] <= 20'd0;r_hist_cnt[30] <= 20'd0;r_hist_cnt[31] <= 20'd0;r_hist_cnt[32] <= 20'd0;r_hist_cnt[33] <= 20'd0;r_hist_cnt[34] <= 20'd0;r_hist_cnt[35] <= 20'd0;r_hist_cnt[36] <= 20'd0;r_hist_cnt[37] <= 20'd0;r_hist_cnt[38] <= 20'd0;r_hist_cnt[39] <= 20'd0;r_hist_cnt[40] <= 20'd0;r_hist_cnt[41] <= 20'd0;r_hist_cnt[42] <= 20'd0;r_hist_cnt[43] <= 20'd0;r_hist_cnt[44] <= 20'd0;r_hist_cnt[45] <= 20'd0;r_hist_cnt[46] <= 20'd0;r_hist_cnt[47] <= 20'd0;r_hist_cnt[48] <= 20'd0;r_hist_cnt[49] <= 20'd0;r_hist_cnt[50] <= 20'd0;r_hist_cnt[51] <= 20'd0;r_hist_cnt[52] <= 20'd0;r_hist_cnt[53] <= 20'd0;r_hist_cnt[54] <= 20'd0;r_hist_cnt[55] <= 20'd0;r_hist_cnt[56] <= 20'd0;r_hist_cnt[57] <= 20'd0;r_hist_cnt[58] <= 20'd0;r_hist_cnt[59] <= 20'd0;r_hist_cnt[60] <= 20'd0;r_hist_cnt[61] <= 20'd0;r_hist_cnt[62] <= 20'd0;r_hist_cnt[63] <= 20'd0;r_hist_cnt[64] <= 20'd0;r_hist_cnt[65] <= 20'd0;r_hist_cnt[66] <= 20'd0;r_hist_cnt[67] <= 20'd0;r_hist_cnt[68] <= 20'd0;r_hist_cnt[69] <= 20'd0;r_hist_cnt[70] <= 20'd0;r_hist_cnt[71] <= 20'd0;r_hist_cnt[72] <= 20'd0;r_hist_cnt[73] <= 20'd0;r_hist_cnt[74] <= 20'd0;r_hist_cnt[75] <= 20'd0;r_hist_cnt[76] <= 20'd0;r_hist_cnt[77] <= 20'd0;r_hist_cnt[78] <= 20'd0;r_hist_cnt[79] <= 20'd0;r_hist_cnt[80] <= 20'd0;r_hist_cnt[81] <= 20'd0;r_hist_cnt[82] <= 20'd0;r_hist_cnt[83] <= 20'd0;r_hist_cnt[84] <= 20'd0;r_hist_cnt[85] <= 20'd0;r_hist_cnt[86] <= 20'd0;r_hist_cnt[87] <= 20'd0;r_hist_cnt[88] <= 20'd0;r_hist_cnt[89] <= 20'd0;r_hist_cnt[90] <= 20'd0;r_hist_cnt[91] <= 20'd0;r_hist_cnt[92] <= 20'd0;r_hist_cnt[93] <= 20'd0;r_hist_cnt[94] <= 20'd0;r_hist_cnt[95] <= 20'd0;r_hist_cnt[96] <= 20'd0;r_hist_cnt[97] <= 20'd0;r_hist_cnt[98] <= 20'd0;r_hist_cnt[99] <= 20'd0;r_hist_cnt[100] <= 20'd0;r_hist_cnt[101] <= 20'd0;r_hist_cnt[102] <= 20'd0;r_hist_cnt[103] <= 20'd0;r_hist_cnt[104] <= 20'd0;r_hist_cnt[105] <= 20'd0;r_hist_cnt[106] <= 20'd0;r_hist_cnt[107] <= 20'd0;r_hist_cnt[108] <= 20'd0;r_hist_cnt[109] <= 20'd0;r_hist_cnt[110] <= 20'd0;r_hist_cnt[111] <= 20'd0;r_hist_cnt[112] <= 20'd0;r_hist_cnt[113] <= 20'd0;r_hist_cnt[114] <= 20'd0;r_hist_cnt[115] <= 20'd0;r_hist_cnt[116] <= 20'd0;r_hist_cnt[117] <= 20'd0;r_hist_cnt[118] <= 20'd0;r_hist_cnt[119] <= 20'd0;r_hist_cnt[120] <= 20'd0;r_hist_cnt[121] <= 20'd0;r_hist_cnt[122] <= 20'd0;r_hist_cnt[123] <= 20'd0;r_hist_cnt[124] <= 20'd0;r_hist_cnt[125] <= 20'd0;r_hist_cnt[126] <= 20'd0;r_hist_cnt[127] <= 20'd0;r_hist_cnt[128] <= 20'd0;r_hist_cnt[129] <= 20'd0;r_hist_cnt[130] <= 20'd0;r_hist_cnt[131] <= 20'd0;r_hist_cnt[132] <= 20'd0;r_hist_cnt[133] <= 20'd0;r_hist_cnt[134] <= 20'd0;r_hist_cnt[135] <= 20'd0;r_hist_cnt[136] <= 20'd0;r_hist_cnt[137] <= 20'd0;r_hist_cnt[138] <= 20'd0;r_hist_cnt[139] <= 20'd0;r_hist_cnt[140] <= 20'd0;r_hist_cnt[141] <= 20'd0;r_hist_cnt[142] <= 20'd0;r_hist_cnt[143] <= 20'd0;r_hist_cnt[144] <= 20'd0;r_hist_cnt[145] <= 20'd0;r_hist_cnt[146] <= 20'd0;r_hist_cnt[147] <= 20'd0;r_hist_cnt[148] <= 20'd0;r_hist_cnt[149] <= 20'd0;r_hist_cnt[150] <= 20'd0;r_hist_cnt[151] <= 20'd0;r_hist_cnt[152] <= 20'd0;r_hist_cnt[153] <= 20'd0;r_hist_cnt[154] <= 20'd0;r_hist_cnt[155] <= 20'd0;r_hist_cnt[156] <= 20'd0;r_hist_cnt[157] <= 20'd0;r_hist_cnt[158] <= 20'd0;r_hist_cnt[159] <= 20'd0;r_hist_cnt[160] <= 20'd0;r_hist_cnt[161] <= 20'd0;r_hist_cnt[162] <= 20'd0;r_hist_cnt[163] <= 20'd0;r_hist_cnt[164] <= 20'd0;r_hist_cnt[165] <= 20'd0;r_hist_cnt[166] <= 20'd0;r_hist_cnt[167] <= 20'd0;r_hist_cnt[168] <= 20'd0;r_hist_cnt[169] <= 20'd0;r_hist_cnt[170] <= 20'd0;r_hist_cnt[171] <= 20'd0;r_hist_cnt[172] <= 20'd0;r_hist_cnt[173] <= 20'd0;r_hist_cnt[174] <= 20'd0;r_hist_cnt[175] <= 20'd0;r_hist_cnt[176] <= 20'd0;r_hist_cnt[177] <= 20'd0;r_hist_cnt[178] <= 20'd0;r_hist_cnt[179] <= 20'd0;r_hist_cnt[180] <= 20'd0;r_hist_cnt[181] <= 20'd0;r_hist_cnt[182] <= 20'd0;r_hist_cnt[183] <= 20'd0;r_hist_cnt[184] <= 20'd0;r_hist_cnt[185] <= 20'd0;r_hist_cnt[186] <= 20'd0;r_hist_cnt[187] <= 20'd0;r_hist_cnt[188] <= 20'd0;r_hist_cnt[189] <= 20'd0;r_hist_cnt[190] <= 20'd0;r_hist_cnt[191] <= 20'd0;r_hist_cnt[192] <= 20'd0;r_hist_cnt[193] <= 20'd0;r_hist_cnt[194] <= 20'd0;r_hist_cnt[195] <= 20'd0;r_hist_cnt[196] <= 20'd0;r_hist_cnt[197] <= 20'd0;r_hist_cnt[198] <= 20'd0;r_hist_cnt[199] <= 20'd0;r_hist_cnt[200] <= 20'd0;r_hist_cnt[201] <= 20'd0;r_hist_cnt[202] <= 20'd0;r_hist_cnt[203] <= 20'd0;r_hist_cnt[204] <= 20'd0;r_hist_cnt[205] <= 20'd0;r_hist_cnt[206] <= 20'd0;r_hist_cnt[207] <= 20'd0;r_hist_cnt[208] <= 20'd0;r_hist_cnt[209] <= 20'd0;r_hist_cnt[210] <= 20'd0;r_hist_cnt[211] <= 20'd0;r_hist_cnt[212] <= 20'd0;r_hist_cnt[213] <= 20'd0;r_hist_cnt[214] <= 20'd0;r_hist_cnt[215] <= 20'd0;r_hist_cnt[216] <= 20'd0;r_hist_cnt[217] <= 20'd0;r_hist_cnt[218] <= 20'd0;r_hist_cnt[219] <= 20'd0;r_hist_cnt[220] <= 20'd0;r_hist_cnt[221] <= 20'd0;r_hist_cnt[222] <= 20'd0;r_hist_cnt[223] <= 20'd0;r_hist_cnt[224] <= 20'd0;r_hist_cnt[225] <= 20'd0;r_hist_cnt[226] <= 20'd0;r_hist_cnt[227] <= 20'd0;r_hist_cnt[228] <= 20'd0;r_hist_cnt[229] <= 20'd0;r_hist_cnt[230] <= 20'd0;r_hist_cnt[231] <= 20'd0;r_hist_cnt[232] <= 20'd0;r_hist_cnt[233] <= 20'd0;r_hist_cnt[234] <= 20'd0;r_hist_cnt[235] <= 20'd0;r_hist_cnt[236] <= 20'd0;r_hist_cnt[237] <= 20'd0;r_hist_cnt[238] <= 20'd0;r_hist_cnt[239] <= 20'd0;r_hist_cnt[240] <= 20'd0;r_hist_cnt[241] <= 20'd0;r_hist_cnt[242] <= 20'd0;r_hist_cnt[243] <= 20'd0;r_hist_cnt[244] <= 20'd0;r_hist_cnt[245] <= 20'd0;r_hist_cnt[246] <= 20'd0;r_hist_cnt[247] <= 20'd0;r_hist_cnt[248] <= 20'd0;r_hist_cnt[249] <= 20'd0;r_hist_cnt[250] <= 20'd0;r_hist_cnt[251] <= 20'd0;r_hist_cnt[252] <= 20'd0;r_hist_cnt[253] <= 20'd0;r_hist_cnt[254] <= 20'd0;r_hist_cnt[255] <= 20'd0;end else if(i_image_vld)begincase(i_image_data)8'd0:r_hist_cnt[0] <=r_hist_cnt[0] + 1;8'd1:r_hist_cnt[1] <=r_hist_cnt[1] + 1;8'd2:r_hist_cnt[2] <=r_hist_cnt[2] + 1;8'd3:r_hist_cnt[3] <=r_hist_cnt[3] + 1;8'd4:r_hist_cnt[4] <=r_hist_cnt[4] + 1;8'd5:r_hist_cnt[5] <=r_hist_cnt[5] + 1;8'd6:r_hist_cnt[6] <=r_hist_cnt[6] + 1;8'd7:r_hist_cnt[7] <=r_hist_cnt[7] + 1;8'd8:r_hist_cnt[8] <=r_hist_cnt[8] + 1;8'd9:r_hist_cnt[9] <=r_hist_cnt[9] + 1;8'd10:r_hist_cnt[10] <=r_hist_cnt[10] + 1;8'd11:r_hist_cnt[11] <=r_hist_cnt[11] + 1;8'd12:r_hist_cnt[12] <=r_hist_cnt[12] + 1;8'd13:r_hist_cnt[13] <=r_hist_cnt[13] + 1;8'd14:r_hist_cnt[14] <=r_hist_cnt[14] + 1;8'd15:r_hist_cnt[15] <=r_hist_cnt[15] + 1;8'd16:r_hist_cnt[16] <=r_hist_cnt[16] + 1;8'd17:r_hist_cnt[17] <=r_hist_cnt[17] + 1;8'd18:r_hist_cnt[18] <=r_hist_cnt[18] + 1;8'd19:r_hist_cnt[19] <=r_hist_cnt[19] + 1;8'd20:r_hist_cnt[20] <=r_hist_cnt[20] + 1;8'd21:r_hist_cnt[21] <=r_hist_cnt[21] + 1;8'd22:r_hist_cnt[22] <=r_hist_cnt[22] + 1;8'd23:r_hist_cnt[23] <=r_hist_cnt[23] + 1;8'd24:r_hist_cnt[24] <=r_hist_cnt[24] + 1;8'd25:r_hist_cnt[25] <=r_hist_cnt[25] + 1;8'd26:r_hist_cnt[26] <=r_hist_cnt[26] + 1;8'd27:r_hist_cnt[27] <=r_hist_cnt[27] + 1;8'd28:r_hist_cnt[28] <=r_hist_cnt[28] + 1;8'd29:r_hist_cnt[29] <=r_hist_cnt[29] + 1;8'd30:r_hist_cnt[30] <=r_hist_cnt[30] + 1;8'd31:r_hist_cnt[31] <=r_hist_cnt[31] + 1;8'd32:r_hist_cnt[32] <=r_hist_cnt[32] + 1;8'd33:r_hist_cnt[33] <=r_hist_cnt[33] + 1;8'd34:r_hist_cnt[34] <=r_hist_cnt[34] + 1;8'd35:r_hist_cnt[35] <=r_hist_cnt[35] + 1;8'd36:r_hist_cnt[36] <=r_hist_cnt[36] + 1;8'd37:r_hist_cnt[37] <=r_hist_cnt[37] + 1;8'd38:r_hist_cnt[38] <=r_hist_cnt[38] + 1;8'd39:r_hist_cnt[39] <=r_hist_cnt[39] + 1;8'd40:r_hist_cnt[40] <=r_hist_cnt[40] + 1;8'd41:r_hist_cnt[41] <=r_hist_cnt[41] + 1;8'd42:r_hist_cnt[42] <=r_hist_cnt[42] + 1;8'd43:r_hist_cnt[43] <=r_hist_cnt[43] + 1;8'd44:r_hist_cnt[44] <=r_hist_cnt[44] + 1;8'd45:r_hist_cnt[45] <=r_hist_cnt[45] + 1;8'd46:r_hist_cnt[46] <=r_hist_cnt[46] + 1;8'd47:r_hist_cnt[47] <=r_hist_cnt[47] + 1;8'd48:r_hist_cnt[48] <=r_hist_cnt[48] + 1;8'd49:r_hist_cnt[49] <=r_hist_cnt[49] + 1;8'd50:r_hist_cnt[50] <=r_hist_cnt[50] + 1;8'd51:r_hist_cnt[51] <=r_hist_cnt[51] + 1;8'd52:r_hist_cnt[52] <=r_hist_cnt[52] + 1;8'd53:r_hist_cnt[53] <=r_hist_cnt[53] + 1;8'd54:r_hist_cnt[54] <=r_hist_cnt[54] + 1;8'd55:r_hist_cnt[55] <=r_hist_cnt[55] + 1;8'd56:r_hist_cnt[56] <=r_hist_cnt[56] + 1;8'd57:r_hist_cnt[57] <=r_hist_cnt[57] + 1;8'd58:r_hist_cnt[58] <=r_hist_cnt[58] + 1;8'd59:r_hist_cnt[59] <=r_hist_cnt[59] + 1;8'd60:r_hist_cnt[60] <=r_hist_cnt[60] + 1;8'd61:r_hist_cnt[61] <=r_hist_cnt[61] + 1;8'd62:r_hist_cnt[62] <=r_hist_cnt[62] + 1;8'd63:r_hist_cnt[63] <=r_hist_cnt[63] + 1;8'd64:r_hist_cnt[64] <=r_hist_cnt[64] + 1;8'd65:r_hist_cnt[65] <=r_hist_cnt[65] + 1;8'd66:r_hist_cnt[66] <=r_hist_cnt[66] + 1;8'd67:r_hist_cnt[67] <=r_hist_cnt[67] + 1;8'd68:r_hist_cnt[68] <=r_hist_cnt[68] + 1;8'd69:r_hist_cnt[69] <=r_hist_cnt[69] + 1;8'd70:r_hist_cnt[70] <=r_hist_cnt[70] + 1;8'd71:r_hist_cnt[71] <=r_hist_cnt[71] + 1;8'd72:r_hist_cnt[72] <=r_hist_cnt[72] + 1;8'd73:r_hist_cnt[73] <=r_hist_cnt[73] + 1;8'd74:r_hist_cnt[74] <=r_hist_cnt[74] + 1;8'd75:r_hist_cnt[75] <=r_hist_cnt[75] + 1;8'd76:r_hist_cnt[76] <=r_hist_cnt[76] + 1;8'd77:r_hist_cnt[77] <=r_hist_cnt[77] + 1;8'd78:r_hist_cnt[78] <=r_hist_cnt[78] + 1;8'd79:r_hist_cnt[79] <=r_hist_cnt[79] + 1;8'd80:r_hist_cnt[80] <=r_hist_cnt[80] + 1;8'd81:r_hist_cnt[81] <=r_hist_cnt[81] + 1;8'd82:r_hist_cnt[82] <=r_hist_cnt[82] + 1;8'd83:r_hist_cnt[83] <=r_hist_cnt[83] + 1;8'd84:r_hist_cnt[84] <=r_hist_cnt[84] + 1;8'd85:r_hist_cnt[85] <=r_hist_cnt[85] + 1;8'd86:r_hist_cnt[86] <=r_hist_cnt[86] + 1;8'd87:r_hist_cnt[87] <=r_hist_cnt[87] + 1;8'd88:r_hist_cnt[88] <=r_hist_cnt[88] + 1;8'd89:r_hist_cnt[89] <=r_hist_cnt[89] + 1;8'd90:r_hist_cnt[90] <=r_hist_cnt[90] + 1;8'd91:r_hist_cnt[91] <=r_hist_cnt[91] + 1;8'd92:r_hist_cnt[92] <=r_hist_cnt[92] + 1;8'd93:r_hist_cnt[93] <=r_hist_cnt[93] + 1;8'd94:r_hist_cnt[94] <=r_hist_cnt[94] + 1;8'd95:r_hist_cnt[95] <=r_hist_cnt[95] + 1;8'd96:r_hist_cnt[96] <=r_hist_cnt[96] + 1;8'd97:r_hist_cnt[97] <=r_hist_cnt[97] + 1;8'd98:r_hist_cnt[98] <=r_hist_cnt[98] + 1;8'd99:r_hist_cnt[99] <=r_hist_cnt[99] + 1;8'd100:r_hist_cnt[100] <=r_hist_cnt[100] + 1;8'd101:r_hist_cnt[101] <=r_hist_cnt[101] + 1;8'd102:r_hist_cnt[102] <=r_hist_cnt[102] + 1;8'd103:r_hist_cnt[103] <=r_hist_cnt[103] + 1;8'd104:r_hist_cnt[104] <=r_hist_cnt[104] + 1;8'd105:r_hist_cnt[105] <=r_hist_cnt[105] + 1;8'd106:r_hist_cnt[106] <=r_hist_cnt[106] + 1;8'd107:r_hist_cnt[107] <=r_hist_cnt[107] + 1;8'd108:r_hist_cnt[108] <=r_hist_cnt[108] + 1;8'd109:r_hist_cnt[109] <=r_hist_cnt[109] + 1;8'd110:r_hist_cnt[110] <=r_hist_cnt[110] + 1;8'd111:r_hist_cnt[111] <=r_hist_cnt[111] + 1;8'd112:r_hist_cnt[112] <=r_hist_cnt[112] + 1;8'd113:r_hist_cnt[113] <=r_hist_cnt[113] + 1;8'd114:r_hist_cnt[114] <=r_hist_cnt[114] + 1;8'd115:r_hist_cnt[115] <=r_hist_cnt[115] + 1;8'd116:r_hist_cnt[116] <=r_hist_cnt[116] + 1;8'd117:r_hist_cnt[117] <=r_hist_cnt[117] + 1;8'd118:r_hist_cnt[118] <=r_hist_cnt[118] + 1;8'd119:r_hist_cnt[119] <=r_hist_cnt[119] + 1;8'd120:r_hist_cnt[120] <=r_hist_cnt[120] + 1;8'd121:r_hist_cnt[121] <=r_hist_cnt[121] + 1;8'd122:r_hist_cnt[122] <=r_hist_cnt[122] + 1;8'd123:r_hist_cnt[123] <=r_hist_cnt[123] + 1;8'd124:r_hist_cnt[124] <=r_hist_cnt[124] + 1;8'd125:r_hist_cnt[125] <=r_hist_cnt[125] + 1;8'd126:r_hist_cnt[126] <=r_hist_cnt[126] + 1;8'd127:r_hist_cnt[127] <=r_hist_cnt[127] + 1;8'd128:r_hist_cnt[128] <=r_hist_cnt[128] + 1;8'd129:r_hist_cnt[129] <=r_hist_cnt[129] + 1;8'd130:r_hist_cnt[130] <=r_hist_cnt[130] + 1;8'd131:r_hist_cnt[131] <=r_hist_cnt[131] + 1;8'd132:r_hist_cnt[132] <=r_hist_cnt[132] + 1;8'd133:r_hist_cnt[133] <=r_hist_cnt[133] + 1;8'd134:r_hist_cnt[134] <=r_hist_cnt[134] + 1;8'd135:r_hist_cnt[135] <=r_hist_cnt[135] + 1;8'd136:r_hist_cnt[136] <=r_hist_cnt[136] + 1;8'd137:r_hist_cnt[137] <=r_hist_cnt[137] + 1;8'd138:r_hist_cnt[138] <=r_hist_cnt[138] + 1;8'd139:r_hist_cnt[139] <=r_hist_cnt[139] + 1;8'd140:r_hist_cnt[140] <=r_hist_cnt[140] + 1;8'd141:r_hist_cnt[141] <=r_hist_cnt[141] + 1;8'd142:r_hist_cnt[142] <=r_hist_cnt[142] + 1;8'd143:r_hist_cnt[143] <=r_hist_cnt[143] + 1;8'd144:r_hist_cnt[144] <=r_hist_cnt[144] + 1;8'd145:r_hist_cnt[145] <=r_hist_cnt[145] + 1;8'd146:r_hist_cnt[146] <=r_hist_cnt[146] + 1;8'd147:r_hist_cnt[147] <=r_hist_cnt[147] + 1;8'd148:r_hist_cnt[148] <=r_hist_cnt[148] + 1;8'd149:r_hist_cnt[149] <=r_hist_cnt[149] + 1;8'd150:r_hist_cnt[150] <=r_hist_cnt[150] + 1;8'd151:r_hist_cnt[151] <=r_hist_cnt[151] + 1;8'd152:r_hist_cnt[152] <=r_hist_cnt[152] + 1;8'd153:r_hist_cnt[153] <=r_hist_cnt[153] + 1;8'd154:r_hist_cnt[154] <=r_hist_cnt[154] + 1;8'd155:r_hist_cnt[155] <=r_hist_cnt[155] + 1;8'd156:r_hist_cnt[156] <=r_hist_cnt[156] + 1;8'd157:r_hist_cnt[157] <=r_hist_cnt[157] + 1;8'd158:r_hist_cnt[158] <=r_hist_cnt[158] + 1;8'd159:r_hist_cnt[159] <=r_hist_cnt[159] + 1;8'd160:r_hist_cnt[160] <=r_hist_cnt[160] + 1;8'd161:r_hist_cnt[161] <=r_hist_cnt[161] + 1;8'd162:r_hist_cnt[162] <=r_hist_cnt[162] + 1;8'd163:r_hist_cnt[163] <=r_hist_cnt[163] + 1;8'd164:r_hist_cnt[164] <=r_hist_cnt[164] + 1;8'd165:r_hist_cnt[165] <=r_hist_cnt[165] + 1;8'd166:r_hist_cnt[166] <=r_hist_cnt[166] + 1;8'd167:r_hist_cnt[167] <=r_hist_cnt[167] + 1;8'd168:r_hist_cnt[168] <=r_hist_cnt[168] + 1;8'd169:r_hist_cnt[169] <=r_hist_cnt[169] + 1;8'd170:r_hist_cnt[170] <=r_hist_cnt[170] + 1;8'd171:r_hist_cnt[171] <=r_hist_cnt[171] + 1;8'd172:r_hist_cnt[172] <=r_hist_cnt[172] + 1;8'd173:r_hist_cnt[173] <=r_hist_cnt[173] + 1;8'd174:r_hist_cnt[174] <=r_hist_cnt[174] + 1;8'd175:r_hist_cnt[175] <=r_hist_cnt[175] + 1;8'd176:r_hist_cnt[176] <=r_hist_cnt[176] + 1;8'd177:r_hist_cnt[177] <=r_hist_cnt[177] + 1;8'd178:r_hist_cnt[178] <=r_hist_cnt[178] + 1;8'd179:r_hist_cnt[179] <=r_hist_cnt[179] + 1;8'd180:r_hist_cnt[180] <=r_hist_cnt[180] + 1;8'd181:r_hist_cnt[181] <=r_hist_cnt[181] + 1;8'd182:r_hist_cnt[182] <=r_hist_cnt[182] + 1;8'd183:r_hist_cnt[183] <=r_hist_cnt[183] + 1;8'd184:r_hist_cnt[184] <=r_hist_cnt[184] + 1;8'd185:r_hist_cnt[185] <=r_hist_cnt[185] + 1;8'd186:r_hist_cnt[186] <=r_hist_cnt[186] + 1;8'd187:r_hist_cnt[187] <=r_hist_cnt[187] + 1;8'd188:r_hist_cnt[188] <=r_hist_cnt[188] + 1;8'd189:r_hist_cnt[189] <=r_hist_cnt[189] + 1;8'd190:r_hist_cnt[190] <=r_hist_cnt[190] + 1;8'd191:r_hist_cnt[191] <=r_hist_cnt[191] + 1;8'd192:r_hist_cnt[192] <=r_hist_cnt[192] + 1;8'd193:r_hist_cnt[193] <=r_hist_cnt[193] + 1;8'd194:r_hist_cnt[194] <=r_hist_cnt[194] + 1;8'd195:r_hist_cnt[195] <=r_hist_cnt[195] + 1;8'd196:r_hist_cnt[196] <=r_hist_cnt[196] + 1;8'd197:r_hist_cnt[197] <=r_hist_cnt[197] + 1;8'd198:r_hist_cnt[198] <=r_hist_cnt[198] + 1;8'd199:r_hist_cnt[199] <=r_hist_cnt[199] + 1;8'd200:r_hist_cnt[200] <=r_hist_cnt[200] + 1;8'd201:r_hist_cnt[201] <=r_hist_cnt[201] + 1;8'd202:r_hist_cnt[202] <=r_hist_cnt[202] + 1;8'd203:r_hist_cnt[203] <=r_hist_cnt[203] + 1;8'd204:r_hist_cnt[204] <=r_hist_cnt[204] + 1;8'd205:r_hist_cnt[205] <=r_hist_cnt[205] + 1;8'd206:r_hist_cnt[206] <=r_hist_cnt[206] + 1;8'd207:r_hist_cnt[207] <=r_hist_cnt[207] + 1;8'd208:r_hist_cnt[208] <=r_hist_cnt[208] + 1;8'd209:r_hist_cnt[209] <=r_hist_cnt[209] + 1;8'd210:r_hist_cnt[210] <=r_hist_cnt[210] + 1;8'd211:r_hist_cnt[211] <=r_hist_cnt[211] + 1;8'd212:r_hist_cnt[212] <=r_hist_cnt[212] + 1;8'd213:r_hist_cnt[213] <=r_hist_cnt[213] + 1;8'd214:r_hist_cnt[214] <=r_hist_cnt[214] + 1;8'd215:r_hist_cnt[215] <=r_hist_cnt[215] + 1;8'd216:r_hist_cnt[216] <=r_hist_cnt[216] + 1;8'd217:r_hist_cnt[217] <=r_hist_cnt[217] + 1;8'd218:r_hist_cnt[218] <=r_hist_cnt[218] + 1;8'd219:r_hist_cnt[219] <=r_hist_cnt[219] + 1;8'd220:r_hist_cnt[220] <=r_hist_cnt[220] + 1;8'd221:r_hist_cnt[221] <=r_hist_cnt[221] + 1;8'd222:r_hist_cnt[222] <=r_hist_cnt[222] + 1;8'd223:r_hist_cnt[223] <=r_hist_cnt[223] + 1;8'd224:r_hist_cnt[224] <=r_hist_cnt[224] + 1;8'd225:r_hist_cnt[225] <=r_hist_cnt[225] + 1;8'd226:r_hist_cnt[226] <=r_hist_cnt[226] + 1;8'd227:r_hist_cnt[227] <=r_hist_cnt[227] + 1;8'd228:r_hist_cnt[228] <=r_hist_cnt[228] + 1;8'd229:r_hist_cnt[229] <=r_hist_cnt[229] + 1;8'd230:r_hist_cnt[230] <=r_hist_cnt[230] + 1;8'd231:r_hist_cnt[231] <=r_hist_cnt[231] + 1;8'd232:r_hist_cnt[232] <=r_hist_cnt[232] + 1;8'd233:r_hist_cnt[233] <=r_hist_cnt[233] + 1;8'd234:r_hist_cnt[234] <=r_hist_cnt[234] + 1;8'd235:r_hist_cnt[235] <=r_hist_cnt[235] + 1;8'd236:r_hist_cnt[236] <=r_hist_cnt[236] + 1;8'd237:r_hist_cnt[237] <=r_hist_cnt[237] + 1;8'd238:r_hist_cnt[238] <=r_hist_cnt[238] + 1;8'd239:r_hist_cnt[239] <=r_hist_cnt[239] + 1;8'd240:r_hist_cnt[240] <=r_hist_cnt[240] + 1;8'd241:r_hist_cnt[241] <=r_hist_cnt[241] + 1;8'd242:r_hist_cnt[242] <=r_hist_cnt[242] + 1;8'd243:r_hist_cnt[243] <=r_hist_cnt[243] + 1;8'd244:r_hist_cnt[244] <=r_hist_cnt[244] + 1;8'd245:r_hist_cnt[245] <=r_hist_cnt[245] + 1;8'd246:r_hist_cnt[246] <=r_hist_cnt[246] + 1;8'd247:r_hist_cnt[247] <=r_hist_cnt[247] + 1;8'd248:r_hist_cnt[248] <=r_hist_cnt[248] + 1;8'd249:r_hist_cnt[249] <=r_hist_cnt[249] + 1;8'd250:r_hist_cnt[250] <=r_hist_cnt[250] + 1;8'd251:r_hist_cnt[251] <=r_hist_cnt[251] + 1;8'd252:r_hist_cnt[252] <=r_hist_cnt[252] + 1;8'd253:r_hist_cnt[253] <=r_hist_cnt[253] + 1;8'd254:r_hist_cnt[254] <=r_hist_cnt[254] + 1;8'd255:r_hist_cnt[255] <=r_hist_cnt[255] + 1;default:;endcaseend else;end 	//输入像素计数器,一张图片已经输入了多少个像素
reg[19:0] r_pix_cnt;
wire w_one_frame_done;//一帧图像处理完成标志
always@(posedge i_clk) beginif(!i_rst_n)r_pix_cnt <= 20'd0;else if(w_one_frame_done)//计满一帧图像是,计数器清零。r_pix_cnt <=0;else if(i_image_vld)r_pix_cnt <= r_pix_cnt + 1;else;
end assign w_one_frame_done = (r_pix_cnt==P_IMAGE_SIZE)?1:0;//直方图统计结果输出计数reg [8:0] r_result_cnt;always@(posedge i_clk) beginif(!i_rst_n)r_result_cnt<=9'd0;else if(w_one_frame_done)r_result_cnt <= 9'd1;else if( (r_result_cnt>9'd0) && (r_result_cnt<9'd256)) r_result_cnt <= r_result_cnt +1;elser_result_cnt<=9'd0;
end //直方图统计结果的输出
//output reg o_result_rdy,
//output reg [19:0] o_result_data
always@(posedge i_clk) beginif(!i_rst_n)o_result_rdy <= 0;else if(r_result_cnt !=9'd0)o_result_rdy <= 1;elseo_result_rdy <=0;
end 	always@(posedge i_clk) begino_result_data <= r_hist_cnt[r_result_cnt-1];
end 	endmodule

直方图滤波的Matalb实现可以参考我另一篇博客,里面详细介绍了直方图滤波的原理:
MATLAB图像处理之【直方图均衡】传送门

--晓凡  2024428日于武汉书

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/4642.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Spark核心名词解释与编程

Spark核心概念 名词解释 1)ClusterManager&#xff1a;在Standalone(上述安装的模式&#xff0c;也就是依托于spark集群本身)模式中即为Master&#xff08;主节点&#xff09;&#xff0c;控制整个集群&#xff0c;监控Worker。在YARN模式中为资源管理器ResourceManager(国内…

paddlehub的简单应用

1、下载安装 pip install paddlehub -i https://pypi.tuna.tsinghua.edu.cn/simple 报错&#xff1a; Collecting onnx<1.9.0 (from paddle2onnx>0.5.1->paddlehub)Using cached https://pypi.tuna.tsinghua.edu.cn/packages/73/e9/5b953497c0e36df589fc60cc6c6b35…

Redux数据流架构

Redux的难点是理解它对于数据修改的规则, 下图动态展示了在整个数据的修改中&#xff0c;数据的流向 Redux代码被分为三个核心的概念&#xff0c;三个概念分别是: state: 一个对象 存放着我们管理的数据action: 一个对象 用来描述你想怎么改数据reducer: 一个函数 根据action的…

万兆以太网MAC设计(11)完整UDP协议栈仿真

文章目录 前言一、模块接口二、IP模块与ARP模块之间的联系三、整体协议栈仿真总结&#xff1a; 前言 目前除了巨帧处理逻辑之外&#xff0c;所有的准备工作都已经结束了&#xff0c;先进行整体的功能验证。 一、模块接口 所有模块接口皆采用AXIS数据流的形式&#xff0c;其中…

用Jenkins实现cherry-pick多个未入库的gerrit编译Android固件

背景: 在做Android固件开发的时候,通常我们可以利用gerrit-trigger插件,开发者提交一笔的时候自动触发jenkins编译,如果提交的这一笔的编译依赖其他gerrit才能编译过,我们可以在commit message中加入特殊字段,让jenkins在编译此笔patch的时候同时抓取依赖的gerrit代码下…

java后端项目:视积分抽奖平台

一、项目背景: 本次抽奖系统实现是在视频中内置一个线上活动抽奖系统,奖品是在一个时间段区间内均匀发布,用户可以在这个时间段内参与抽奖。 二、项目架构 活动抽奖平台采用微服务架构来完成,在功能上实现拆分为用户、网关、以及抽奖微服务,其中用户、网关是后台项目通…

三. TensorRT基础入门-TensorRT内部的优化模块

目录 前言0. 简述1.TensorRT的优化策略2. Layer Fusion3. Kernel Auto-Tuning4. Quantization总结参考 前言 自动驾驶之心推出的 《CUDA与TensorRT部署实战课程》&#xff0c;链接。记录下个人学习笔记&#xff0c;仅供自己参考 本次课程我们来学习课程第三章—TensorRT 基础入…

C++ | 类和对象(上)

目录 什么是类 类的介绍 struct在两种语言中的有何区别 私有变量命名注意点 类的作用域 类的声明定义分离 类的访问限定符 封装 类的实例化 类对象的存储 this指针 一道this指针相关的王炸题&#xff1a; 结语 什么是类 类的介绍 我们举一个日常生活中的例子&…

罗宾斯《管理学》第15版笔记/课后习题/考研真题答案

第Ⅰ篇 管理导论 第1章 工作场所中的管理者和你 1.1 知识结构导图 1.2 考点难点归纳 1.3 课后习题详解 1.4 考研真题详解 附加模块一 管理史 知识结构导图 考点难点归纳 课后习题详解 考研真题详解 第2章 决 策 2.1 知识结构导图 2.2 考点难点归纳 2.3 课后习题详解…

C之·标准库<string.h>

系列文章目录 文章目录 前言一、字符串分割函数1.strtok()2. 总结 前言 <stdlib.h> 是C语言中的一个头文件&#xff0c;提供了一系列用于操作字符串的函数。例如查找子字符串、拼接字符串、比较字符串等等。为了方便开发者进行字符串操作&#xff0c;C语言提供了一个标准…

python爬虫学习-------scrapy的第一部分(二十九天)

&#x1f388;&#x1f388;作者主页&#xff1a; 喔的嘛呀&#x1f388;&#x1f388; &#x1f388;&#x1f388;所属专栏&#xff1a;python爬虫学习&#x1f388;&#x1f388; ✨✨谢谢大家捧场&#xff0c;祝屏幕前的小伙伴们每天都有好运相伴左右&#xff0c;一定要天天…

做App小程序h5的软件 校园小程序有哪些小程序源码平台 微信小程序里发表的展示圈子 怎么将小程序分享到朋友圈小程序社区 小程序在大学校

最近几年&#xff0c;校园外卖跑腿服务市场迅速兴起。由于学生每天课程繁忙&#xff0c;很多人没有时间去食堂或外面的餐厅用餐&#xff0c;校园外卖跑腿平台提供了便捷和快速的解决方案&#xff0c;满足了学生的饮食跑腿需求&#xff0c;并受到越来越多学生的喜爱。 那么&…

C语言程序设计(二)

1、算法、数据结构、程序 为解决一个问题而采取的方法和步骤&#xff0c;就称为“算法”。 2、算法的5大特征 3、判断n是否为素数&#xff1a;只需要从2循环到根号n。 优化原理&#xff1a;素数是因子为1和本身&#xff0c; 如果num不是素数&#xff0c;则还有其他因子&…

stm32单片机开发三、DMA

DMA其实就是一种将ADC的数据寄存器、串口的数据寄存器等等一些数据放到sram中特定位置&#xff0c;方便CPU去读取 比如ADC转换&#xff0c;DMA直接转换的ADC的值放在内存中的特定位置&#xff0c;CPU可以直接去读取 uint16_t AD_Value[4]; //定义用于存放AD转换结果的全局…

上市企业数字赋能指数数据集-2001到2022年(TF-IDF)

01、数据简介 上市公司数字赋能指数是一个用来衡量上市公司利用数字技术提高业务能力和效率的指标。这个指数反映了上市公司利用大数据、云计算和人工智能等数字技术&#xff0c;高效地利用商业资源和信息&#xff0c;并扩展供应关系的能力。市公司数字赋能指数是一种综合性的…

怎么给字符串字段加索引?

怎么给字符串字段加索引&#xff1f; 现在&#xff0c;几乎所有的系统都支持邮箱登录&#xff0c;如何在邮箱这样的字段上建立合理的索引&#xff0c;是我们今天要讨论的问题。 假设&#xff0c;你现在维护一个支持邮箱登录的系统&#xff0c;用户表是这么定义的&#xff1a; …

美富特 | 邀您参加2024全国水科技大会暨技术装备成果展览会

王涛 四川美源环能科技有限公司 技术总监 报告题目&#xff1a;绿色智慧水岛如何助力工业园区污水及再生水资源化利用降碳增效 拥有十余年的环保行业从业经验&#xff0c;对各类前沿物化、生化及膜技术均有丰富的研发、设计及应用经验&#xff0c;先后参与多项重点核心技术…

日本宇宙航空研究“Int-Ball2”自由飞行相机机器人采用的Epson IMU

IMU有助于飞行的稳定控制和电池充电的自动对接- 精工爱普生公司&#xff08;TSE:6724&#xff0c;“Epson”&#xff09;很高兴地宣布&#xff0c;日本宇宙航空研究开发机构&#xff08;JAXA&#xff09;选择了爱普生M-G370系列的惯性测量单元&#xff08;IMU&#xff09;&…

开源相机管理库Aravis例程学习(五)——camera-api

开源相机管理库Aravis例程学习&#xff08;五&#xff09;——camera-api 简介例程代码函数说明arv_camera_get_regionarv_camera_get_pixel_format_as_stringarv_camera_get_pixel_formatARV_PIXEL_FORMAT_BIT_PER_PIXEL 简介 本文针对官方例程中的&#xff1a;03-camera-api…

Swift - 可选项(Optional)

文章目录 Swift - 可选项&#xff08;Optional&#xff09;1. 可选项&#xff08;Optional&#xff09;2. 强制解包&#xff08;Forced Unwrapping&#xff09;3. 判断可选项是否包含值4. 可选项绑定&#xff08;Optional Binding&#xff09;5. 等价写法6. while循环中使用可选…