How to find the rectangle with those text
$begingroup$
In this image:
I want to find this rectangle with all contents(without those grid's lines)
I think the total of the pixels can help a little like:
img = Import["http://i.stack.imgur.com/lnd5w.png"];
data = Total[ImageData[ImageRotate[ColorNegate[img]]]];
Show[ImageRotate[img],
ListLinePlot[data, PlotRange -> All, PlotStyle -> Red]]
And I have such images:
image2
image3
image4
image5
I have no idea to do this thing. Does anyone have an idea?
image-processing signal-processing
$endgroup$
add a comment |
$begingroup$
In this image:
I want to find this rectangle with all contents(without those grid's lines)
I think the total of the pixels can help a little like:
img = Import["http://i.stack.imgur.com/lnd5w.png"];
data = Total[ImageData[ImageRotate[ColorNegate[img]]]];
Show[ImageRotate[img],
ListLinePlot[data, PlotRange -> All, PlotStyle -> Red]]
And I have such images:
image2
image3
image4
image5
I have no idea to do this thing. Does anyone have an idea?
image-processing signal-processing
$endgroup$
1
$begingroup$
Have you asked this question before? It seems very familiar to me...
$endgroup$
– Carl Lange
Dec 28 '18 at 14:36
$begingroup$
Ah, I was thinking of this and this. Just for context purposes :)
$endgroup$
– Carl Lange
Dec 28 '18 at 14:37
$begingroup$
@CarlLange It's not very similar...
$endgroup$
– yode
Dec 28 '18 at 14:37
$begingroup$
The question isn't but the images are, so I wanted to make sure it wasn't a duplicate somehow. That's all!
$endgroup$
– Carl Lange
Dec 28 '18 at 15:10
add a comment |
$begingroup$
In this image:
I want to find this rectangle with all contents(without those grid's lines)
I think the total of the pixels can help a little like:
img = Import["http://i.stack.imgur.com/lnd5w.png"];
data = Total[ImageData[ImageRotate[ColorNegate[img]]]];
Show[ImageRotate[img],
ListLinePlot[data, PlotRange -> All, PlotStyle -> Red]]
And I have such images:
image2
image3
image4
image5
I have no idea to do this thing. Does anyone have an idea?
image-processing signal-processing
$endgroup$
In this image:
I want to find this rectangle with all contents(without those grid's lines)
I think the total of the pixels can help a little like:
img = Import["http://i.stack.imgur.com/lnd5w.png"];
data = Total[ImageData[ImageRotate[ColorNegate[img]]]];
Show[ImageRotate[img],
ListLinePlot[data, PlotRange -> All, PlotStyle -> Red]]
And I have such images:
image2
image3
image4
image5
I have no idea to do this thing. Does anyone have an idea?
image-processing signal-processing
image-processing signal-processing
edited Jan 3 at 10:52
yode
asked Dec 28 '18 at 13:57
yodeyode
10.4k234103
10.4k234103
1
$begingroup$
Have you asked this question before? It seems very familiar to me...
$endgroup$
– Carl Lange
Dec 28 '18 at 14:36
$begingroup$
Ah, I was thinking of this and this. Just for context purposes :)
$endgroup$
– Carl Lange
Dec 28 '18 at 14:37
$begingroup$
@CarlLange It's not very similar...
$endgroup$
– yode
Dec 28 '18 at 14:37
$begingroup$
The question isn't but the images are, so I wanted to make sure it wasn't a duplicate somehow. That's all!
$endgroup$
– Carl Lange
Dec 28 '18 at 15:10
add a comment |
1
$begingroup$
Have you asked this question before? It seems very familiar to me...
$endgroup$
– Carl Lange
Dec 28 '18 at 14:36
$begingroup$
Ah, I was thinking of this and this. Just for context purposes :)
$endgroup$
– Carl Lange
Dec 28 '18 at 14:37
$begingroup$
@CarlLange It's not very similar...
$endgroup$
– yode
Dec 28 '18 at 14:37
$begingroup$
The question isn't but the images are, so I wanted to make sure it wasn't a duplicate somehow. That's all!
$endgroup$
– Carl Lange
Dec 28 '18 at 15:10
1
1
$begingroup$
Have you asked this question before? It seems very familiar to me...
$endgroup$
– Carl Lange
Dec 28 '18 at 14:36
$begingroup$
Have you asked this question before? It seems very familiar to me...
$endgroup$
– Carl Lange
Dec 28 '18 at 14:36
$begingroup$
Ah, I was thinking of this and this. Just for context purposes :)
$endgroup$
– Carl Lange
Dec 28 '18 at 14:37
$begingroup$
Ah, I was thinking of this and this. Just for context purposes :)
$endgroup$
– Carl Lange
Dec 28 '18 at 14:37
$begingroup$
@CarlLange It's not very similar...
$endgroup$
– yode
Dec 28 '18 at 14:37
$begingroup$
@CarlLange It's not very similar...
$endgroup$
– yode
Dec 28 '18 at 14:37
$begingroup$
The question isn't but the images are, so I wanted to make sure it wasn't a duplicate somehow. That's all!
$endgroup$
– Carl Lange
Dec 28 '18 at 15:10
$begingroup$
The question isn't but the images are, so I wanted to make sure it wasn't a duplicate somehow. That's all!
$endgroup$
– Carl Lange
Dec 28 '18 at 15:10
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
Binarization and ComponentMeasurements
seems the straightforward solution:
img = Import["https://i.stack.imgur.com/lnd5w.png"];
Selct all components that are less than half as long as the image:
comp = ComponentMeasurements[MorphologicalBinarize[ColorNegate@img],
"BoundingBox", #CaliperLength < Min[ImageDimensions[img]]*0.5 &];
This selects all digits and boxes, but not the grid lines, because they are longer than height/2:
HighlightImage[img, Rectangle @@@ comp[[All, 2]]]
Then combine the individual bounding boxes to one big bounding box:
HighlightImage[img,
Rectangle @@
Transpose[MinMax /@ Transpose[Flatten[comp[[All, 2]], 1]]]]
You might have to adjust binarization and the criteria in ComponentMeasurements
, but for me, it worked on all the images you posted on the first try.
$endgroup$
$begingroup$
Sorry for catching a cold to delay response. Your method is very simple to understand. But your method cannot deal with the image5. This is why I want to do it with signal-processing method...
$endgroup$
– yode
Jan 3 at 10:54
$begingroup$
@yode: Sure it can, you just need to adjust the criteria function inComponentMeasurements
.
$endgroup$
– Niki Estner
Jan 3 at 11:13
add a comment |
$begingroup$
This works quite well:
findRegion[img_] := TextRecognize[img, "BoundingBox", RecognitionPrior -> "SparseText"]
HighlightImage[#, findRegion@#] & /@ imgs
As you can see, the result for the first image is not perfect unfortunately, but hopefully this gives you some ideas.
$endgroup$
$begingroup$
Yes, as your try, the Tesseract not very stable..
$endgroup$
– yode
Dec 28 '18 at 14:40
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f188497%2fhow-to-find-the-rectangle-with-those-text%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Binarization and ComponentMeasurements
seems the straightforward solution:
img = Import["https://i.stack.imgur.com/lnd5w.png"];
Selct all components that are less than half as long as the image:
comp = ComponentMeasurements[MorphologicalBinarize[ColorNegate@img],
"BoundingBox", #CaliperLength < Min[ImageDimensions[img]]*0.5 &];
This selects all digits and boxes, but not the grid lines, because they are longer than height/2:
HighlightImage[img, Rectangle @@@ comp[[All, 2]]]
Then combine the individual bounding boxes to one big bounding box:
HighlightImage[img,
Rectangle @@
Transpose[MinMax /@ Transpose[Flatten[comp[[All, 2]], 1]]]]
You might have to adjust binarization and the criteria in ComponentMeasurements
, but for me, it worked on all the images you posted on the first try.
$endgroup$
$begingroup$
Sorry for catching a cold to delay response. Your method is very simple to understand. But your method cannot deal with the image5. This is why I want to do it with signal-processing method...
$endgroup$
– yode
Jan 3 at 10:54
$begingroup$
@yode: Sure it can, you just need to adjust the criteria function inComponentMeasurements
.
$endgroup$
– Niki Estner
Jan 3 at 11:13
add a comment |
$begingroup$
Binarization and ComponentMeasurements
seems the straightforward solution:
img = Import["https://i.stack.imgur.com/lnd5w.png"];
Selct all components that are less than half as long as the image:
comp = ComponentMeasurements[MorphologicalBinarize[ColorNegate@img],
"BoundingBox", #CaliperLength < Min[ImageDimensions[img]]*0.5 &];
This selects all digits and boxes, but not the grid lines, because they are longer than height/2:
HighlightImage[img, Rectangle @@@ comp[[All, 2]]]
Then combine the individual bounding boxes to one big bounding box:
HighlightImage[img,
Rectangle @@
Transpose[MinMax /@ Transpose[Flatten[comp[[All, 2]], 1]]]]
You might have to adjust binarization and the criteria in ComponentMeasurements
, but for me, it worked on all the images you posted on the first try.
$endgroup$
$begingroup$
Sorry for catching a cold to delay response. Your method is very simple to understand. But your method cannot deal with the image5. This is why I want to do it with signal-processing method...
$endgroup$
– yode
Jan 3 at 10:54
$begingroup$
@yode: Sure it can, you just need to adjust the criteria function inComponentMeasurements
.
$endgroup$
– Niki Estner
Jan 3 at 11:13
add a comment |
$begingroup$
Binarization and ComponentMeasurements
seems the straightforward solution:
img = Import["https://i.stack.imgur.com/lnd5w.png"];
Selct all components that are less than half as long as the image:
comp = ComponentMeasurements[MorphologicalBinarize[ColorNegate@img],
"BoundingBox", #CaliperLength < Min[ImageDimensions[img]]*0.5 &];
This selects all digits and boxes, but not the grid lines, because they are longer than height/2:
HighlightImage[img, Rectangle @@@ comp[[All, 2]]]
Then combine the individual bounding boxes to one big bounding box:
HighlightImage[img,
Rectangle @@
Transpose[MinMax /@ Transpose[Flatten[comp[[All, 2]], 1]]]]
You might have to adjust binarization and the criteria in ComponentMeasurements
, but for me, it worked on all the images you posted on the first try.
$endgroup$
Binarization and ComponentMeasurements
seems the straightforward solution:
img = Import["https://i.stack.imgur.com/lnd5w.png"];
Selct all components that are less than half as long as the image:
comp = ComponentMeasurements[MorphologicalBinarize[ColorNegate@img],
"BoundingBox", #CaliperLength < Min[ImageDimensions[img]]*0.5 &];
This selects all digits and boxes, but not the grid lines, because they are longer than height/2:
HighlightImage[img, Rectangle @@@ comp[[All, 2]]]
Then combine the individual bounding boxes to one big bounding box:
HighlightImage[img,
Rectangle @@
Transpose[MinMax /@ Transpose[Flatten[comp[[All, 2]], 1]]]]
You might have to adjust binarization and the criteria in ComponentMeasurements
, but for me, it worked on all the images you posted on the first try.
answered Dec 28 '18 at 15:12
Niki EstnerNiki Estner
31.1k376133
31.1k376133
$begingroup$
Sorry for catching a cold to delay response. Your method is very simple to understand. But your method cannot deal with the image5. This is why I want to do it with signal-processing method...
$endgroup$
– yode
Jan 3 at 10:54
$begingroup$
@yode: Sure it can, you just need to adjust the criteria function inComponentMeasurements
.
$endgroup$
– Niki Estner
Jan 3 at 11:13
add a comment |
$begingroup$
Sorry for catching a cold to delay response. Your method is very simple to understand. But your method cannot deal with the image5. This is why I want to do it with signal-processing method...
$endgroup$
– yode
Jan 3 at 10:54
$begingroup$
@yode: Sure it can, you just need to adjust the criteria function inComponentMeasurements
.
$endgroup$
– Niki Estner
Jan 3 at 11:13
$begingroup$
Sorry for catching a cold to delay response. Your method is very simple to understand. But your method cannot deal with the image5. This is why I want to do it with signal-processing method...
$endgroup$
– yode
Jan 3 at 10:54
$begingroup$
Sorry for catching a cold to delay response. Your method is very simple to understand. But your method cannot deal with the image5. This is why I want to do it with signal-processing method...
$endgroup$
– yode
Jan 3 at 10:54
$begingroup$
@yode: Sure it can, you just need to adjust the criteria function in
ComponentMeasurements
.$endgroup$
– Niki Estner
Jan 3 at 11:13
$begingroup$
@yode: Sure it can, you just need to adjust the criteria function in
ComponentMeasurements
.$endgroup$
– Niki Estner
Jan 3 at 11:13
add a comment |
$begingroup$
This works quite well:
findRegion[img_] := TextRecognize[img, "BoundingBox", RecognitionPrior -> "SparseText"]
HighlightImage[#, findRegion@#] & /@ imgs
As you can see, the result for the first image is not perfect unfortunately, but hopefully this gives you some ideas.
$endgroup$
$begingroup$
Yes, as your try, the Tesseract not very stable..
$endgroup$
– yode
Dec 28 '18 at 14:40
add a comment |
$begingroup$
This works quite well:
findRegion[img_] := TextRecognize[img, "BoundingBox", RecognitionPrior -> "SparseText"]
HighlightImage[#, findRegion@#] & /@ imgs
As you can see, the result for the first image is not perfect unfortunately, but hopefully this gives you some ideas.
$endgroup$
$begingroup$
Yes, as your try, the Tesseract not very stable..
$endgroup$
– yode
Dec 28 '18 at 14:40
add a comment |
$begingroup$
This works quite well:
findRegion[img_] := TextRecognize[img, "BoundingBox", RecognitionPrior -> "SparseText"]
HighlightImage[#, findRegion@#] & /@ imgs
As you can see, the result for the first image is not perfect unfortunately, but hopefully this gives you some ideas.
$endgroup$
This works quite well:
findRegion[img_] := TextRecognize[img, "BoundingBox", RecognitionPrior -> "SparseText"]
HighlightImage[#, findRegion@#] & /@ imgs
As you can see, the result for the first image is not perfect unfortunately, but hopefully this gives you some ideas.
answered Dec 28 '18 at 14:13
Lukas LangLukas Lang
7,31511032
7,31511032
$begingroup$
Yes, as your try, the Tesseract not very stable..
$endgroup$
– yode
Dec 28 '18 at 14:40
add a comment |
$begingroup$
Yes, as your try, the Tesseract not very stable..
$endgroup$
– yode
Dec 28 '18 at 14:40
$begingroup$
Yes, as your try, the Tesseract not very stable..
$endgroup$
– yode
Dec 28 '18 at 14:40
$begingroup$
Yes, as your try, the Tesseract not very stable..
$endgroup$
– yode
Dec 28 '18 at 14:40
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f188497%2fhow-to-find-the-rectangle-with-those-text%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
$begingroup$
Have you asked this question before? It seems very familiar to me...
$endgroup$
– Carl Lange
Dec 28 '18 at 14:36
$begingroup$
Ah, I was thinking of this and this. Just for context purposes :)
$endgroup$
– Carl Lange
Dec 28 '18 at 14:37
$begingroup$
@CarlLange It's not very similar...
$endgroup$
– yode
Dec 28 '18 at 14:37
$begingroup$
The question isn't but the images are, so I wanted to make sure it wasn't a duplicate somehow. That's all!
$endgroup$
– Carl Lange
Dec 28 '18 at 15:10