How to count tablets successfully?Face recognition LibraryPeak detection in a 2D arraySimple and fast method to compare images for similarityHow do I find Waldo with Mathematica?Image Processing: Algorithm Improvement for 'Coca-Cola Can' RecognitionSegmentation for connected charactersImage Processing - Counting nucleiRobust image segmentation in OpenCVDistance Transform in OpenCV Python automatically converting CV_8UC3 to CV_32SC1 creating an assertion errorImage segmentation with watershed thresholding

Why does there seem to be an extreme lack of public trashcans in Taiwan?

My players want to use called-shots on Strahd

Boss making me feel guilty for leaving the company at the end of my internship

What happens when one target of Paradoxical Outcome becomes illegal?

Can artificial satellite positions affect tides?

Realistic, logical way for men with medieval-era weaponry to compete with much larger and physically stronger foes

Should I worry about having my credit pulled multiple times while car shopping?

Why is C++ template use not recommended in space/radiated environment?

A flower's head or heart?

Harley Davidson clattering noise from engine, backfire and failure to start

How Many Times To Repeat An Event With Known Probability Before It Has Occurred A Number of Times

ISP is not hashing the password I log in with online. Should I take any action?

I sent an angry e-mail to my interviewers about a conflict at my home institution. Could this affect my application?

How can I detect if I'm in a subshell?

What do I need to do, tax-wise, for a sudden windfall?

Arrows inside a commutative diagram using tikzcd

Are athletes' college degrees discounted by employers and graduate school admissions?

Certain list transform

Can an escape pod land on Earth from orbit and not be immediately detected?

Does an African-American baby born in Youngstown, Ohio have a higher infant mortality rate than a baby born in Iran?

Manager wants to hire me; HR does not. How to proceed?

In The Incredibles 2, why does Screenslaver's name use a pun on something that doesn't exist in the 1950s pastiche?

Can a 40amp breaker be used safely and without issue with a 40amp device on 6AWG wire?

What publication claimed that Michael Jackson died in a nuclear holocaust?



How to count tablets successfully?


Face recognition LibraryPeak detection in a 2D arraySimple and fast method to compare images for similarityHow do I find Waldo with Mathematica?Image Processing: Algorithm Improvement for 'Coca-Cola Can' RecognitionSegmentation for connected charactersImage Processing - Counting nucleiRobust image segmentation in OpenCVDistance Transform in OpenCV Python automatically converting CV_8UC3 to CV_32SC1 creating an assertion errorImage segmentation with watershed thresholding






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















My last question on image recognition seemed to be too broad, so I would like to ask a more concrete question.



First the background. I have already developed a (round) pill counter. It uses something similar to this tutorial. After I made it I also found something similar with this other tutorial.



However my method fails for something like this image



The original problem



Although the segmentation process is a bit complicated (because of the semi-transparency of the tablets) I have managed to get it



segmented image



My problem is here. How can I count the elongated tablets, separating each one from the image, similar to the final results in the linked tutorials?



I would appreciate if someone can help me to find a solution.



So far I have applied distance transform and then my own version of watershed and I got



bad results



As you can see it fails in the adjacent tablets (distance transform usually does).



Take into account that the solution does have to work for this image and also for other arrangements of the tablets, the most difficult being for example



difficult case



I am open to use OpenCV or if necessary implement on my own algorithms. So far I have tried both (used OpenCV functions and also programmed my own libraries) I am also open to use C++, or python or other. (personally I programmed them in C++ and I have done it on C# too)



Thanks again for the help.










share|improve this question
























  • It can be easily done with cv::distanceTransform()

    – Bahramdun Adil
    Mar 25 at 2:33











  • @BahramdunAdil Could you provide an example? Asi I wrote I already tried distance transform and watershedoing with the results above. It fails. (Mainly when the tablets are next to each other)

    – KansaiRobot
    Mar 25 at 2:38






  • 1





    Didn't you ask that exact same question last week?

    – T A
    Mar 25 at 7:50











  • @TA It was argued my question was too general (well it involved pills and tablets of different sizes and characteristics) so I reduced the question to the first of my problems (in a much more concrete way) (and specifying that it should work for more than the same case)

    – KansaiRobot
    Mar 25 at 8:32











  • Have you tried eroding after using the distance transformation?

    – T A
    Mar 25 at 8:34


















1















My last question on image recognition seemed to be too broad, so I would like to ask a more concrete question.



First the background. I have already developed a (round) pill counter. It uses something similar to this tutorial. After I made it I also found something similar with this other tutorial.



However my method fails for something like this image



The original problem



Although the segmentation process is a bit complicated (because of the semi-transparency of the tablets) I have managed to get it



segmented image



My problem is here. How can I count the elongated tablets, separating each one from the image, similar to the final results in the linked tutorials?



I would appreciate if someone can help me to find a solution.



So far I have applied distance transform and then my own version of watershed and I got



bad results



As you can see it fails in the adjacent tablets (distance transform usually does).



Take into account that the solution does have to work for this image and also for other arrangements of the tablets, the most difficult being for example



difficult case



I am open to use OpenCV or if necessary implement on my own algorithms. So far I have tried both (used OpenCV functions and also programmed my own libraries) I am also open to use C++, or python or other. (personally I programmed them in C++ and I have done it on C# too)



Thanks again for the help.










share|improve this question
























  • It can be easily done with cv::distanceTransform()

    – Bahramdun Adil
    Mar 25 at 2:33











  • @BahramdunAdil Could you provide an example? Asi I wrote I already tried distance transform and watershedoing with the results above. It fails. (Mainly when the tablets are next to each other)

    – KansaiRobot
    Mar 25 at 2:38






  • 1





    Didn't you ask that exact same question last week?

    – T A
    Mar 25 at 7:50











  • @TA It was argued my question was too general (well it involved pills and tablets of different sizes and characteristics) so I reduced the question to the first of my problems (in a much more concrete way) (and specifying that it should work for more than the same case)

    – KansaiRobot
    Mar 25 at 8:32











  • Have you tried eroding after using the distance transformation?

    – T A
    Mar 25 at 8:34














1












1








1


1






My last question on image recognition seemed to be too broad, so I would like to ask a more concrete question.



First the background. I have already developed a (round) pill counter. It uses something similar to this tutorial. After I made it I also found something similar with this other tutorial.



However my method fails for something like this image



The original problem



Although the segmentation process is a bit complicated (because of the semi-transparency of the tablets) I have managed to get it



segmented image



My problem is here. How can I count the elongated tablets, separating each one from the image, similar to the final results in the linked tutorials?



I would appreciate if someone can help me to find a solution.



So far I have applied distance transform and then my own version of watershed and I got



bad results



As you can see it fails in the adjacent tablets (distance transform usually does).



Take into account that the solution does have to work for this image and also for other arrangements of the tablets, the most difficult being for example



difficult case



I am open to use OpenCV or if necessary implement on my own algorithms. So far I have tried both (used OpenCV functions and also programmed my own libraries) I am also open to use C++, or python or other. (personally I programmed them in C++ and I have done it on C# too)



Thanks again for the help.










share|improve this question
















My last question on image recognition seemed to be too broad, so I would like to ask a more concrete question.



First the background. I have already developed a (round) pill counter. It uses something similar to this tutorial. After I made it I also found something similar with this other tutorial.



However my method fails for something like this image



The original problem



Although the segmentation process is a bit complicated (because of the semi-transparency of the tablets) I have managed to get it



segmented image



My problem is here. How can I count the elongated tablets, separating each one from the image, similar to the final results in the linked tutorials?



I would appreciate if someone can help me to find a solution.



So far I have applied distance transform and then my own version of watershed and I got



bad results



As you can see it fails in the adjacent tablets (distance transform usually does).



Take into account that the solution does have to work for this image and also for other arrangements of the tablets, the most difficult being for example



difficult case



I am open to use OpenCV or if necessary implement on my own algorithms. So far I have tried both (used OpenCV functions and also programmed my own libraries) I am also open to use C++, or python or other. (personally I programmed them in C++ and I have done it on C# too)



Thanks again for the help.







opencv image-processing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 6:01









marc_s

593k13311351279




593k13311351279










asked Mar 25 at 1:53









KansaiRobotKansaiRobot

1,0241533




1,0241533












  • It can be easily done with cv::distanceTransform()

    – Bahramdun Adil
    Mar 25 at 2:33











  • @BahramdunAdil Could you provide an example? Asi I wrote I already tried distance transform and watershedoing with the results above. It fails. (Mainly when the tablets are next to each other)

    – KansaiRobot
    Mar 25 at 2:38






  • 1





    Didn't you ask that exact same question last week?

    – T A
    Mar 25 at 7:50











  • @TA It was argued my question was too general (well it involved pills and tablets of different sizes and characteristics) so I reduced the question to the first of my problems (in a much more concrete way) (and specifying that it should work for more than the same case)

    – KansaiRobot
    Mar 25 at 8:32











  • Have you tried eroding after using the distance transformation?

    – T A
    Mar 25 at 8:34


















  • It can be easily done with cv::distanceTransform()

    – Bahramdun Adil
    Mar 25 at 2:33











  • @BahramdunAdil Could you provide an example? Asi I wrote I already tried distance transform and watershedoing with the results above. It fails. (Mainly when the tablets are next to each other)

    – KansaiRobot
    Mar 25 at 2:38






  • 1





    Didn't you ask that exact same question last week?

    – T A
    Mar 25 at 7:50











  • @TA It was argued my question was too general (well it involved pills and tablets of different sizes and characteristics) so I reduced the question to the first of my problems (in a much more concrete way) (and specifying that it should work for more than the same case)

    – KansaiRobot
    Mar 25 at 8:32











  • Have you tried eroding after using the distance transformation?

    – T A
    Mar 25 at 8:34

















It can be easily done with cv::distanceTransform()

– Bahramdun Adil
Mar 25 at 2:33





It can be easily done with cv::distanceTransform()

– Bahramdun Adil
Mar 25 at 2:33













@BahramdunAdil Could you provide an example? Asi I wrote I already tried distance transform and watershedoing with the results above. It fails. (Mainly when the tablets are next to each other)

– KansaiRobot
Mar 25 at 2:38





@BahramdunAdil Could you provide an example? Asi I wrote I already tried distance transform and watershedoing with the results above. It fails. (Mainly when the tablets are next to each other)

– KansaiRobot
Mar 25 at 2:38




1




1





Didn't you ask that exact same question last week?

– T A
Mar 25 at 7:50





Didn't you ask that exact same question last week?

– T A
Mar 25 at 7:50













@TA It was argued my question was too general (well it involved pills and tablets of different sizes and characteristics) so I reduced the question to the first of my problems (in a much more concrete way) (and specifying that it should work for more than the same case)

– KansaiRobot
Mar 25 at 8:32





@TA It was argued my question was too general (well it involved pills and tablets of different sizes and characteristics) so I reduced the question to the first of my problems (in a much more concrete way) (and specifying that it should work for more than the same case)

– KansaiRobot
Mar 25 at 8:32













Have you tried eroding after using the distance transformation?

– T A
Mar 25 at 8:34






Have you tried eroding after using the distance transformation?

– T A
Mar 25 at 8:34













1 Answer
1






active

oldest

votes


















0














Given that the pills are all identical and don’t overlap, simply divide the total pill area by the area of a single pill.



The area is estimated simply counting the number of “pill” pixels.



You do need to calibrate the method by giving it the area of a single pill. This can be trivially obtained by giving the correct solution to one of the images (manual counting), then all the other images can be counted automatically.






share|improve this answer























  • Ideally I would like to have them marked as in pyimagesearch.com/wp-content/uploads/2015/10/… (the pic is for round coins, but similar for tablets)

    – KansaiRobot
    Mar 26 at 1:50












  • @KansaiRobot: Sure, you can try doing it the hard way if you want. Good luck with that!

    – Cris Luengo
    Mar 26 at 1:53











  • Unfortunatelly it is a requirement.

    – KansaiRobot
    Mar 26 at 1:56











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330370%2fhow-to-count-tablets-successfully%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Given that the pills are all identical and don’t overlap, simply divide the total pill area by the area of a single pill.



The area is estimated simply counting the number of “pill” pixels.



You do need to calibrate the method by giving it the area of a single pill. This can be trivially obtained by giving the correct solution to one of the images (manual counting), then all the other images can be counted automatically.






share|improve this answer























  • Ideally I would like to have them marked as in pyimagesearch.com/wp-content/uploads/2015/10/… (the pic is for round coins, but similar for tablets)

    – KansaiRobot
    Mar 26 at 1:50












  • @KansaiRobot: Sure, you can try doing it the hard way if you want. Good luck with that!

    – Cris Luengo
    Mar 26 at 1:53











  • Unfortunatelly it is a requirement.

    – KansaiRobot
    Mar 26 at 1:56















0














Given that the pills are all identical and don’t overlap, simply divide the total pill area by the area of a single pill.



The area is estimated simply counting the number of “pill” pixels.



You do need to calibrate the method by giving it the area of a single pill. This can be trivially obtained by giving the correct solution to one of the images (manual counting), then all the other images can be counted automatically.






share|improve this answer























  • Ideally I would like to have them marked as in pyimagesearch.com/wp-content/uploads/2015/10/… (the pic is for round coins, but similar for tablets)

    – KansaiRobot
    Mar 26 at 1:50












  • @KansaiRobot: Sure, you can try doing it the hard way if you want. Good luck with that!

    – Cris Luengo
    Mar 26 at 1:53











  • Unfortunatelly it is a requirement.

    – KansaiRobot
    Mar 26 at 1:56













0












0








0







Given that the pills are all identical and don’t overlap, simply divide the total pill area by the area of a single pill.



The area is estimated simply counting the number of “pill” pixels.



You do need to calibrate the method by giving it the area of a single pill. This can be trivially obtained by giving the correct solution to one of the images (manual counting), then all the other images can be counted automatically.






share|improve this answer













Given that the pills are all identical and don’t overlap, simply divide the total pill area by the area of a single pill.



The area is estimated simply counting the number of “pill” pixels.



You do need to calibrate the method by giving it the area of a single pill. This can be trivially obtained by giving the correct solution to one of the images (manual counting), then all the other images can be counted automatically.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 25 at 13:19









Cris LuengoCris Luengo

25.7k62457




25.7k62457












  • Ideally I would like to have them marked as in pyimagesearch.com/wp-content/uploads/2015/10/… (the pic is for round coins, but similar for tablets)

    – KansaiRobot
    Mar 26 at 1:50












  • @KansaiRobot: Sure, you can try doing it the hard way if you want. Good luck with that!

    – Cris Luengo
    Mar 26 at 1:53











  • Unfortunatelly it is a requirement.

    – KansaiRobot
    Mar 26 at 1:56

















  • Ideally I would like to have them marked as in pyimagesearch.com/wp-content/uploads/2015/10/… (the pic is for round coins, but similar for tablets)

    – KansaiRobot
    Mar 26 at 1:50












  • @KansaiRobot: Sure, you can try doing it the hard way if you want. Good luck with that!

    – Cris Luengo
    Mar 26 at 1:53











  • Unfortunatelly it is a requirement.

    – KansaiRobot
    Mar 26 at 1:56
















Ideally I would like to have them marked as in pyimagesearch.com/wp-content/uploads/2015/10/… (the pic is for round coins, but similar for tablets)

– KansaiRobot
Mar 26 at 1:50






Ideally I would like to have them marked as in pyimagesearch.com/wp-content/uploads/2015/10/… (the pic is for round coins, but similar for tablets)

– KansaiRobot
Mar 26 at 1:50














@KansaiRobot: Sure, you can try doing it the hard way if you want. Good luck with that!

– Cris Luengo
Mar 26 at 1:53





@KansaiRobot: Sure, you can try doing it the hard way if you want. Good luck with that!

– Cris Luengo
Mar 26 at 1:53













Unfortunatelly it is a requirement.

– KansaiRobot
Mar 26 at 1:56





Unfortunatelly it is a requirement.

– KansaiRobot
Mar 26 at 1:56



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • 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.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330370%2fhow-to-count-tablets-successfully%23new-answer', 'question_page');

);

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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript