We propose our own optimization methods to speed up the work and compare different approaches for high-quality implementation of the idea. The subproblem of the first stage in image processing is a filtration. As a result of the research, can distinguish the following main types of noises: additive and impulse. The impulse is associated with losses in the transmissions through a communication channels. We can remove noise using the Gaussian blur, whichcan be used from the OpenCV library. The purpose of the first stage is to identify the edges, because with the development of technology, it simplifies the operation of data processing algorithms, and thus the storage and processing of information. The second step is to find out the contours in the image that represent the document, which we want to check. The last step lays in taking the four points, representing the outline of the medical document (found in the second step) and appling a perspective transform to get a top-down image with an angle of 90 degrees, because we need a view at a right angle, since it is more convenient to work with it.