Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Generate Histogram of Image, Using FPGA and Verilog

Status
Not open for further replies.

yupina-chan

Member level 2
Joined
Nov 27, 2013
Messages
51
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
397
hi. i want to take the histogram of each box on an image. supposing my image is like the one below, for simplicity, i have a 12x12 image. i want to take the histogram of boxA, boxB and so on. can you suggest on how to do this?

i'm going to implement this in an fpga board using verilog

4697957000_1392708537.png
 
Last edited:

Just keep track if the pixel position and put the result into the correct hostigram. You need 9 histograms for this image. Depending on the max bin sizes will affect how many rams you need.
 

how can i keep track of the pixel? well, i already started with my own.

can you please look at my code?

it saves the pixels to designated box as it enters but the histogram computation isn't working. i was able to save the pixels within the box but with the histogram part, i used a 2d array which is a failure. i'm not sure if this will work in the implementation. there's not much documentation about this that i can find. i intend to have 256 bins.
 

Attachments

  • buffer.rar
    8.6 MB · Views: 227

you can keep the track of the pixel position by reading the above pixels..use a stream based approach so that you can read the pixel above the current pixel by using a shift register...you can have a look at the book "Design for Embedded Image Processing on FPGAs -- Donald g bailey"

Its a very good book for image processing using FPGA's
 

Do you know that a Quartus archive containing all relevant project files has a size of 11 kB?

Also stripping off the unwanted db directories reduces the archive size by 9/10.
 

If your not doing any filtering shift registers are not required. You just need an x and y count to track where you are.
 

I'll look up your code but, it will depend how it's the data available, BRAM, registers, stream per pixel, or whatever. Also another considerations like or preferences, performance or resources.

Edit:
Basically the simple way for mi would be considering as a stream and analizing the value of each pixel one by one, until the end of the image.

Edit2: Just check the code and It'll take more time, more comments would help. Does this code should be synthesizable?
 
Last edited:

hi. i changed my code considering the pixels as streaming. i have no problem saving my pixels to corresponding boxes but i needed to take the histogram of each of the box as shown in the image. that's like 12*16=192 boxes. how should i implement this since my memory is limited, so i can't have 192 histograms with 256 bins(it is required to have 256 bins) all at the same time. my image is 640x480 px.



each box is 40x40. the codes should be synthesizable for board implementation. my new codes are:
 

Attachments

  • histogram.txt
    5.2 KB · Views: 205
  • line_buffer.txt
    2.2 KB · Views: 134
Last edited:

you could empty them (off load them to somewhere else like a processor) when you get to the end of the right most histogram. ie. you only need 12 that you re-use.
 
thanks TrickyDicky for the tip. i will look into it. and will try reusing the histogram.

- - - Updated - - -

i have another question. let's say i will have 6 histograms. in initializing it, i used:
Code:
reg [7:0] hist0[0:255];			
reg [7:0] hist1[0:255];			
reg [7:0] hist2[0:255];			
reg [7:0] hist3[0:255];			
reg [7:0] hist4[0:255];			
reg [7:0] hist5[0:255];			

integer j;
initial begin
	for (j = 0; j < 256; j = j + 1)
		hist0[j] = 0; end
initial begin
	for (j = 0; j < 256; j = j + 1)
		hist1[j] = 0; end
initial begin
	for (j = 0; j < 256; j = j + 1)
		hist2[j] = 0; end
initial begin
	for (j = 0; j < 256; j = j + 1)
		hist3[j] = 0; end
initial begin
	for (j = 0; j < 256; j = j + 1)
		hist4[j] = 0; end
initial begin
	for (j = 0; j < 256; j = j + 1)
		hist5[j] = 0; end

how can i initialize it in another way? or should i use $readmemh/b to save space instead? thanks in advance

omg. so dumb of me. i can't have histograms which are less than the number of my boxes in either column or row. so i should have either 16 or 12 histograms and reuse them for another column/row. such a waste of time. by the way, thanks everyone for the replies.
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top