문제 설명
C++ 이미지 처리, 입자 계산 (C++ image processing, counting particles)
이미지의 입자 수를 계산하고 싶습니다. http://imagej.net/Particle_Analysis 필요한 작업을 정확히 수행하는 ImageJ를 찾았지만 Java이고 통합해야 하는 기능 중 하나일 뿐이므로 C++ 응용 프로그램에서 Java 프로그램을 호출하는 것은 가치가 없습니다. 나는 이것을 구현하는 C++ 라이브러리를 찾고 있는데, 어떤 포괄적인 알고리즘도 환영합니다. 최고입니다
참조 솔루션
방법 1:
I think CImg would be a great solution for you ‑ it is here. It is single C++ header file ‑ no libraries or anything to link and it runs on just about any platform ‑ Linux, OS X, Windows.
The function you need is label()
. Here is a short example:
#include <iostream>
#include "CImg.h"
using namespace std;
using namespace cimg_library;
int main(int argc, char** const argv)
{
CImg<int> img("input.png");
img.label(0,0);
img.save_png("result.png");
}
I made a test image with ImageMagick like this at the command line:
convert ‑size 1000x1000 xc:black ‑fill white \
‑draw "rectangle 10,10 50,50" \
‑draw "rectangle 100,200 300,400" \
‑draw "rectangle 800,25 900,900" input.png
It looks like this:
Then, when you run the program it labels each blob (i.e. rectangle) with an increasing number, i.e. each one is a bit brighter than the last.
방법 2:
have a look at openCV http://opencv.org/. They have a plethora of functions and algorithms related to computer vision. Depending on the shape and structure of the particles in your image the SimpleBlobDetector() may or may not be usefull. There is a good tutorial here: https://www.learnopencv.com/blob‑detection‑using‑opencv‑python‑c/.
Alternativly you could try implement your own algorithm? Have a search for Laplacian of Gaussian kernel. If your particles are an irregular shape, it may become more difficult and require thresholding and contoring.
(by eien sakebe、Mark Setchell、TomJ)