As many will know, images of all US censuses going back to 1790 are available online http://blog.archive.org/2010/12/22/1790-1930-u-s-census-records-available-free/. Unfortunately the quality of the images is very poor in places and, as far as I know, there are no free processed versions of them available. If you take an example like the following from the 1920 census, what would be a good method to extract relatively clean images of the handwritten text from the background image and noise?

The original pdf for the page is at http://wikisend.com/download/737634/page.pdf as I don't have the reputation points to post it here yet (can someone with more rep upload it?).


1 Answer 1


I couldn't open your pdf (antivirus said it was suspicious) so i downloaded an image myself, I don't know if its the right one, but its also from a 1920 census

You could perform image dilation on the document until the text is gone. You can do multiple passes if needed. I just did one. We know dilation will make shrink the black sections (or the text) this essentially gives us just the background.

We then remove the background from the image. This can be tricky depending on the language (I used matlab, and had to make sure to keep the right range and units for the image to display properly) then you have a cleaner image. You should be able to run a ocr engine on the result

enter image description here

and here is a zoomed in section just so you can see the text quality doesn't degrade much with this operation

zoomed pic

and of course the code. As I said it is done in matlab but openCv(in many languages), python, or just about any other image library will be able to perform a similar operation

im = rgb2gray(color_im);
bg = imdilate(im,strel('disk',3));
%we do a complement becasue the bg subtraction makes the text white and 
%the background black. so we invert it
clean = imcomplement(abs(bg-im));

subplot(1,3,1); imshow(im); title('original')
subplot(1,3,2); imshow(bg); title('after imdilate with 3 pixel circle')
subplot(1,3,3); imshow(clean); title('original minus background')

and here is the image I used. Its the first page of the 1920 census https://archive.org/details/fourteenthcensus02unit

enter image description here


I forgot you said it was handwritten images. so I got another sample, same exact code, new image

enter image description here enter image description here

notice the detail even in very dark obscured places, as the zoomed in view shows. You would need to run some other filters, but removing the main background noise is accomplished using dilation


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.