# Help find rectangles with numbers [closed]

I have this picture 1)

Result must be like that 2) . But I can achieve it only if have good numbers with picture like that 3)

With first image I have result: 4) I can't recognize numbers with that picture.

**

## Images: 1)(input) -> 4)(output), 3)(input) -> 2)(output).

**

Image 1) and 3) is pictures for input, 4) and 2) are arrays with real number. Each array has 3 elements.

My main code:

 fnRecognizeRiskData[]:=Block[
{im=Import["C:\\Users\\deo\\Documents\\GDIPlus_Image2.jpg"],binBorders,binMain,background,lengImage,rgRec={},resEnd={},space=,pretext=,row,split},
Print@im;
im=DeleteSmallComponents[im,50];
binBorders=Binarize@im;
background=ColorReplace[Binarize[im,1],Black->White];
binMain=ImageDifference[binBorders,Binarize[im,.9]];
Print@binMain;
binBorders=ImageDifference[binBorders,binMain];
Print@binBorders;
binBorders=RemoveBackground[binBorders];
(*Print@binBorders;*)
binBorders=ImageCompose[background,binBorders];
lengImage=Last@ImageDimensions[tt]/2;
rgRec=ImageCrop@ImageTake[binBorders,#]&/@{lengImage,-lengImage};
PrependTo[rgRec,ImageCrop@ImageCompose[background,RemoveBackground[binMain]]];
rgRec=ImageResize[#,50]&/@rgRec;
Print@rgRec;

(*>block*)](*===========================================*)


• From your examples, I can not perceive how your desired output is supposed to relate to your input images. The numbers shown as output are not found in the input images? Please clarify your question. – m_goldberg Jan 20 '19 at 14:48
• First image(input) relates to forth image(output). Second image(output) relates to third image(input). First number from array(output) relates to grey rectangle in the middle(input) , second number from array(output) relates to white rectangle with number above(input). Third number from array(output) relates to white rectangle with number below(input). – D. Denis Jan 20 '19 at 15:20
• Please explain what is wanted more carefully. As already noted the desired outputs show numbers that are not in the inputs, and vice versa. Stating clearly what are the characteristics that determine which values to retain, and in what order, would clarify matters. – Daniel Lichtblau Jan 20 '19 at 15:54
• You want to extract the numbers that are black on a white or gray background. Is that correct? – Rohit Namjoshi Jan 20 '19 at 16:00
• I want extract 1 number with gray background, black numbers and 2 numbers with white background, black numbers. There's should be 3 elements in array. I don't need numbers with black background, white numbers. My aim is when I have this array I'll want to recognize them in the function TextRecognize[], so I don't need rubbish like in picture #4, element 2ed. Ps Sorry for my English. – D. Denis Jan 20 '19 at 18:45