Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting images only #132

Merged
merged 16 commits into from
Sep 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
avoiding artifact images on the boundary of documents
  • Loading branch information
vahidrezanezhad committed Nov 27, 2023
commit 6aac0b8fafb74046a7c1f5d11419f16b3c2d15ff
34 changes: 32 additions & 2 deletions qurator/eynollah/eynollah.py
Original file line number Diff line number Diff line change
Expand Up @@ -1669,9 +1669,39 @@ def get_regions_light_v_extract_only_images(self,img,is_image_enhanced, num_col_

text_regions_p_true = cv2.fillPoly(text_regions_p_true, pts = polygons_of_only_texts, color=(1,1,1))

polygons_of_images = return_contours_of_interested_region(text_regions_p_true, 2)
polygons_of_images = return_contours_of_interested_region(text_regions_p_true, 2, 0.0001)

return text_regions_p_true, erosion_hurts, polygons_lines_xml, polygons_of_images
image_boundary_of_doc = np.zeros((text_regions_p_true.shape[0], text_regions_p_true.shape[1]))

image_boundary_of_doc[:20, :] = 1
image_boundary_of_doc[text_regions_p_true.shape[0]-20:text_regions_p_true.shape[0], :] = 1

image_boundary_of_doc[:, :20] = 1
image_boundary_of_doc[:, text_regions_p_true.shape[1]-20:text_regions_p_true.shape[1]] = 1

#plt.imshow(image_boundary_of_doc)
#plt.show()

polygons_of_images_fin = []
for ploy_img_ind in polygons_of_images:
test_poly_image = np.zeros((text_regions_p_true.shape[0], text_regions_p_true.shape[1]))
test_poly_image = cv2.fillPoly(test_poly_image, pts = [ploy_img_ind], color=(1,1,1))

test_poly_image = test_poly_image[:,:] + image_boundary_of_doc[:,:]
test_poly_image_intersected_area = ( test_poly_image[:,:]==2 )*1

test_poly_image_intersected_area = test_poly_image_intersected_area.sum()

if test_poly_image_intersected_area==0:
polygons_of_images_fin.append(ploy_img_ind)
#plt.imshow(test_poly_image)
#plt.show()





return text_regions_p_true, erosion_hurts, polygons_lines_xml, polygons_of_images_fin
def get_regions_light_v(self,img,is_image_enhanced, num_col_classifier):
self.logger.debug("enter get_regions_light_v")
erosion_hurts = False
Expand Down
Loading