Showing results for 
Search instead for 
Did you mean: 

Extract the most predominant text from an image



In this article, you will learn the details of how I've managed to extract the most predominant text from an image.

I've recently added a Solution package in the Power Apps Gallery for a sample License Plate Reader.

In the Power Automate flow that uses AI Builder's text recognition that is part of that solution, I have a part that processes the text and extracts only the biggest portion of the results.

Get the know-how by reading on!



YouTube: overview of the solution 

GitHub: solution package to install the app and required resources in your environment.


Blog post: the story behind the app and overall solution.


The Recipe

At this point, I'll presume you have read the blog post that explains the app and flow and you understand that this section of the flow requires to only extract what is the most predominant section of text in the image.

To do so, the steps are as follow:

  1. Initialize the variables
    • PlateNumber: the string that will contain the final result 2019-12-18_5-03-15.png
    • BiggestHeight: the reference to the largest (highest in height) part of text encountered so far 2019-12-18_5-09-24.png
    • VarianceFactor: since this is OCR there could be potential variance factor in size, so this is the level of acceptable tolerance this can be about 2019-12-18_5-09-42.png
    • MaximumHeight and MaximumHeight: boundaries calculated when a new BiggestHeight is found and based on the VarianceFactor, allows to simplify understanding of the formulas in the flow and not having to reprocess them (calculations) in every loop 2019-12-18_5-10-13.png


  2. Loop through the extraction results. In this case, the JSON that is provided by the AI Builder predict action contains 2 sets of arrays we need to process:
    • results
    • lines 
    • 2019-12-18_5-13-32.png
  3. First condition is to validate if the current text size, based on its height, is bigger than the maximum boundary (MaximumHeight), if so: 


    • This is now the new base for our extraction, so set the PlateNumber variable as this current text 2019-12-18_5-15-11.png
  4. Otherwise, ensure that the current text size is within the 2 boundaries (MinimumHeight & MaximumHeight), if so: 2019-12-18_5-15-50.png
    • Append the current text to the end of the PlateNumber variable 2019-12-18_5-16-09.png
  5. Once those 2 conditions have been evaluated, before looping back to the next line within the set of results, evaluate a new condition: is the current height bigger then the last set BiggestHeight variable, if so: 2019-12-18_5-16-27.png
    • Set the BiggestHeight to be as the current height 2019-12-18_5-16-45.png
    • Calculate the boundaries (MinimumHeight & MaximumHeight) based on the VarianceFactor using the following formulas:
      • sub(variables('BiggestHeight'),mul(variables('BiggestHeight'),variables('VarianceFactor')))


This is just another example that even in a low code platform it is possible to perform loops and conditions that allow more complex scenarios to be implemented. Don't hesitate to download the solution from the gallery, edit the flow, adapt it, comment below, etc..


Learn and explore

The Power Platform really allows business users to resolve business issues quickly while ensuring organizations that the safeguards can be put in place to protect their data and reputation. Make sure to learn and explore the capabilities first in a development/community environment. I hope this article has been useful for you, don't hesitate to share and comment back.

About me


I'm Éric Sauvé, aka ZePowerDiver, solution architect and team lead at XRM Vision. Recognized as MCT and Business App MVP. I'm a community leader for TDGi's global hackathons in Canada. Power Platform enthusiast, delivering App in a Day sessions, leading local community events such as Montreal Power Platform Happy Hour, actively participating in Montreal Business Application User Group and speaking in Power Platform and Dynamics CE related conferences.

You can reach me on:



Keep on Diving!



Meet Our Blog Authors
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Cambridge UK Power Platform User Group Leader, Technical evangelist and speaker. Always says yes to coffee! #LetsGetCoffee
  • Passionate #Programmer #SharePoint #SPFx #Office365 #MSFlow | C-sharpCorner MVP | SharePoint StackOverflow, Github, PnP contributor
  • I am building business processes and applications that are easy for users' to stick to, so they can follow and understand them. In overall I transform processes to be more reliable and effortless. I am a proud co-organizer of SharePoint Saturday Warsaw and active community member, blogger and international speaker.