I receive about 500 to 1000 photos of charts or graphs on a daily basis that i have to remove all the components of the photos except their numerical values.

This is an example of my photos:
enter image description here

I select graph bars using Magic Wand Tools in Photoshop:
enter image description here

Then move selected area to between logos and the numerical values:
enter image description here

And finally, by removing the various components of the images, only numerical values remain:
enter image description here

I have to do these steps with Photoshop action feature because the number of my daily photos is very high.
I can do these steps with action feature automatically if the distance between the edge of the graph bars and the first digit of the numerical values is the same in all images. but the main problem here is that the space between the numerical values and the graph bars in the images received daily is not the same.
For example, this is another photo where the distance between the numerical values and the bars of the graph is very close:
enter image description here

If I apply the steps I went through for the previous image using Photoshop action feature on this image, surely some of the numerical values will be removed in this image.

How can I delete all the components of my daily images except the numerical values through the Photoshop action feature?
Can I move selected area exactly to before the numeric values using the Photoshop script?


  1. I can't use Photoshop Color Range tool for selecting numeric values because numeric values have same color as the rest of the image contents.
  2. My daily images have a single layer and are not smart objects.
  3. number of images received daily is very high and I cannot do it manually. I must do it with Photoshop action feature or another automatic solution.
  4. I can't use OCR tool because some of the images contain some logos that contain letters or numbers. If the logo numbers are extracted and combined with numerical values, it is not possible to find the extracted logo numbers.
  5. The space between the graph bar and numerical values in each image is specific and this distance is different between different images.
  6. The space between the graph bar and numerical values in a photo is the same.
  7. All my images resolution is same
  8. It is not a problem if resolution of the photo are changed.
  9. I know that the explanation I provided is complicated, but I could not express my problem more simply than this.

Sorry if there are any spelling errors in the text because my English is very poor. I wrote this text with the help of Google Translate.

If you are following this post, please focus on this as my daily photos may get a lot of changes👇

My daily chart images may be sent in color from the company that i work for. Newly, the values of the bars are double-sided. for example this chart image:

enter image description here

During my review of the images received last week, I found the following relationship:

Image (1) with 3 bars: (first bar height = 580pt) - (first distance between = 820pt) => 820 ÷ 580 = 1.41

Image (2) with 5 bars: (first bar height = 350pt) - (first distance between = 500pt) => 500 ÷ 350 = 1.42

Image (3) with 6 bars: (first bar height = 290pt) - (first distance between = 415pt) => 415 ÷ 290 = 1.43

Image (4) with 8 bars: (first bar height = 220pt) - (first distance between = 315pt) => 315 ÷ 220 = 1.43

If you notice, the answer to almost all of them is ≃1.4 This shows that by multiplying this ratio by the height of the first bar in a image; The distance between the numerical values and the bars of a image is obtained.
Another thing that I noticed is that the ratio (like ≃1.4) obtained in all the images of each day is the same and specific to that day, which must be calculated manually through several random images (3 or 4 images).
I need to calculate this ratio (like ≃1.4) for each daily images through 3 or 4 images and then I need a photoshop script that set this ratio on it to move selection to right exactly before numerical values and finally the selected items are deleted

  • I might be able to come up with something that's a little bit faster than what you do now. But it's a strange workflow to begin with. Isn't it possible to get the numbers from the place that sends you the images?
    – Wolff
    Feb 27, 2023 at 17:18
  • No, unfortunately - I have to remove extra contents from photos and send to company I work for - company use the numerical values in the photos and I don't know how they are used.
    – abo jarba
    Feb 27, 2023 at 17:43
  • I have been facing this very difficult problem for about three months
    – abo jarba
    Feb 27, 2023 at 17:45
  • 2
    There is no soultion for this in photoshop, scripting layer has not enough info to deal with this, so youd have to use something like openCV
    – joojaa
    Mar 8, 2023 at 18:52
  • 1
    I think this is a case of improving communication; get info on what's done with these numbers and discuss a better workflow. If numbers is all they want then it doesn't need to be an image, and perhaps you could get the numbers straight from the source.
    – Luciano
    Mar 9, 2023 at 10:33

3 Answers 3


I don't think this is a graphic design question because PS (or any other graphic software) doesn't really have enough tools to analyse data and in-app scripting here wouldn't help. I was able to get decent results with a simple Python script, using py-tesseract OCR module (simple as in there's nothing fancy about it, some basic knowledge + google).

Here's the algorithm:

  1. first challenge for me was to surely get rid of trash data, especially when they were numbers (second image in the results below). For that I've used PIL (PIL is a default image module) MaxFilter and MinFilter to filter out thin important numbers. Result of Max + Min with the value of 5:

enter image description here

  1. Then I've used blend_modes module to blend this filtered image with the original using the Difference blending mode:

enter image description here

  1. pytesseract can use different options to determine how the text flows, from experimentation I found that page segmentation mode (psm) set to 6 gives the best results;

  2. After running pytesseract.image_to_data() on that image I was getting this result:

{'level': [1, 2, 3, 4, 5, 5, 4, 5, 5, 4, 5, 4, 5, 5], 'page_num': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 'block_num': [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 'par_num': [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 'line_num': [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4], 'word_num': [0, 0, 0, 0, 1, 2, 0, 1, 2, 0, 1, 0, 1, 2], 'left': [0, 248, 248, 424, 424, 484, 342, 342, 388, 250, 250, 248, 248, 294], 'top': [0, 28, 28, 28, 28, 36, 120, 120, 134, 228, 228, 334, 334, 334], 'width': [787, 428, 428, 252, 48, 192, 238, 20, 192, 258, 258, 238, 2, 192], 'height': [399, 346, 346, 56, 56, 40, 60, 60, 40, 40, 40, 40, 2, 40], 'conf': [-1, -1, -1, -1, 0, 0, -1, 61, 79, -1, 45, -1, 0, 66], 'text': ['', '', '', '', '">', '7,660,479', '', '2', '6,131,240', '', '3,700,111', '', '"', '2,217,481']}

'text' property has all the texts that were found on the image, and also there's data on width, height and coordinates of the found blocks. We're interested in blocks that contain at least 3 numbers, so we can filter those out using regex and re module. Knowing indices of these blocks we can then use coordinates to cut out only the ones that are important.

Here's the result with input images on the left, outputs on the right:

enter image description here

  • Neat! What happens if you omit step 1 and 2?
    – Wolff
    Mar 8, 2023 at 20:59
  • 1
    @Wolff thanks! Without those I was getting some false numbers ‘glued’ to correct strings, for example g in the first image was recognized as 6, 4 in the second as 9. It’s possible that images posted here are just compressed though Mar 8, 2023 at 21:12
  • @SergeyKritskiy My main problem is steps 1 and 2! Because in 40% of the images waste is created next to the numerical values that this will confuse scanning tools. In some cases, it even caused OCR tools to recognize numbers as negative or decimal. The last step does not work because some logos may have the same height as the numerical values and the length of the numerical values may be shorter or longer.
    – abo jarba
    Mar 9, 2023 at 13:53
  • @SergeyKritskiy How and with what tool did you do step 4? (last image posted on your answer) => (there's data on width, height and coordinates of the found blocks)
    – abo jarba
    Mar 10, 2023 at 15:53
  • @abojarba it's mentioned in the first paragraph: tesseract Mar 10, 2023 at 16:24

First of all I need to say that I think this workflow is terribly flawed. Someone has the numbers, they turn them into pixels and send them to you to extract the numbers again. Why not just get the numbers from the people who make the graphics?

Anyway, if filtering (like described in the answer by @mirjanaM) doesn't work, I can't see any way you can avoid to at least click once per number.

For example you could use Rectangular Marquee Tool with a Fixed Size. For your example images 235 x 60 px seems to work. (This might not work for the actual images - it seems that you have upscaled these images 400% before posting.)

With Shift pressed, you click once per number like this:

Then you run a prerecorded action that does the following:

  • Invert selection (press Ctrl / Cmd + Shift + I).
  • Fill with white (press Del, set Contents to White and press OK).
  • Save file (Ctrl / Cmd + S).
  • Close file (Ctrl / Cmd + W).

You can assign the action to a shortcut to speed it up a little.

  • I can't use this answer because the numerical values in the images are not in the same place, and due to the larger numerical value, its place may be shifted several millimeters to the right or left!
    – abo jarba
    Mar 7, 2023 at 17:29
  • 1
    My answer requires you to manually find the upper left corner of each number and click once per number. That part is not automated. How long does it take for each click? A second perhaps? That means you'll get through 1000 images with four numbers in each in about an hour. But it won't be fun...
    – Wolff
    Mar 7, 2023 at 17:36

I have created photoshop action and acomplished these results with two of your images. It consists of lot of alternating steps of surface blur, gaussian blur, unsharp mask and levels adjustments. Idea is to make a selection that loses all the numbers then invert. If these results are helpful I can send you action file. I now that numbers don't look the same as on your images but perhaps it is good enough?

First one: first image processed

And the second: second image processed

  • 4
    Describing the actual steps would be helpful to future visitors.
    – Scott
    Mar 2, 2023 at 20:01
  • not problem. please send action file and i will test on 1000 sample images then tell result here.
    – abo jarba
    Mar 3, 2023 at 14:21
  • I was able to do this before with filters such as minimum, maximum and median, but g logo remains. I look forward to trying the filters you used. Please, if you read comments, send action file in new answer of this thread as soon as possible.
    – abo jarba
    Mar 4, 2023 at 13:52
  • I am still waiting for your action file 😁
    – abo jarba
    Mar 5, 2023 at 5:58
  • 4
    @mirjanaM, please describe your method with words in the actual answer. Answers shouldn't rely on people downloading files. One day your file won't be online anymore and your answer won't make any sense.
    – Wolff
    Mar 7, 2023 at 17:06

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.