1 | initial version |
The ring count that I get is 72. Here is a cropped version of your input image:
Here is the code to count the rings:
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(void)
{
Mat frame = imread("rings_slice.png");
if (frame.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
cvtColor(frame, frame, CV_BGR2GRAY);
adaptiveThreshold(frame, frame, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 11, 2);
int column_index = frame.cols / 2 - 1;
int ring_count = 0;
for (int i = 1; i < frame.rows; i++)
{
if (255 == frame.at<unsigned char>(i, column_index) && 0 == frame.at<unsigned char>(i - 1, column_index))
ring_count++;
}
cout << ring_count / 2 << endl;
imshow("frame", frame);
waitKey(0);
return 1;
}
2 | No.2 Revision |
The ring count that I get is 72. Make sure to mark my answer as correct, if you find that it works for you. :)
Here is a cropped version of your input image:
Here is the code to count the rings:
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(void)
{
Mat frame = imread("rings_slice.png");
if (frame.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
cvtColor(frame, frame, CV_BGR2GRAY);
adaptiveThreshold(frame, frame, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 11, 2);
int column_index = frame.cols / 2 - 1;
int ring_count = 0;
for (int i = 1; i < frame.rows; i++)
{
if (255 == frame.at<unsigned char>(i, column_index) && 0 == frame.at<unsigned char>(i - 1, column_index))
ring_count++;
}
cout << ring_count / 2 << endl;
imshow("frame", frame);
waitKey(0);
return 1;
}
3 | No.3 Revision |
The ring count that I get is 72. Make sure to mark my answer as correct, if you find that it works for you. :)
Here is a cropped version of your input image:
Here is the code to count the rings:
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(void)
{
Mat frame = imread("rings_slice.png");
if (frame.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
cvtColor(frame, frame, CV_BGR2GRAY);
adaptiveThreshold(frame, frame, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 11, 2);
int column_index = frame.cols / 2 - 1;
int ring_count = 0;
for (int i = 1; i < frame.rows; i++)
{
if (255 == frame.at<unsigned char>(i, column_index) && 0 == frame.at<unsigned char>(i - 1, column_index))
ring_count++;
}
cout << ring_count / 2 << endl;
imshow("frame", frame);
waitKey(0);
return 1;
}
4 | No.4 Revision |
The ring count that I get is 72. Make sure to mark my answer as correct, if you find that it works for you. :)
Here is a cropped version of your input image: image, which contains only the necessary data:
Here is the code to count the rings:
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(void)
{
Mat frame = imread("rings_slice.png");
if (frame.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
cvtColor(frame, frame, CV_BGR2GRAY);
adaptiveThreshold(frame, frame, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 11, 2);
// Look at centre column
int column_index = frame.cols / 2 - 1;
int ring_count = 0;
// Start with second row
for (int i = 1; i < frame.rows; i++)
{
// If this pixel is white and the previous pixel is black
if (255 == frame.at<unsigned char>(i, column_index) && 0 == frame.at<unsigned char>(i - 1, column_index))
ring_count++;
}
cout << ring_count / 2 << endl;
return 1;
}
5 | No.5 Revision |
The ring count that I get is 72. 70. Make sure to mark my answer as correct, if you find that it works for you. :)
Here is a cropped version of your input image, which contains only the necessary data:
Here is the code to count the rings:
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(void)
{
Mat frame = imread("rings_slice.png");
if (frame.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
cvtColor(frame, frame, CV_BGR2GRAY);
adaptiveThreshold(frame, frame, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 11, 2);
// Look at centre column
int column_index = frame.cols / 2 - 1;
int ring_count = 0;
// Start with second row
for (int i = 1; i < frame.rows; i++)
{
// If this pixel is white and the previous pixel is black
if (255 == frame.at<unsigned char>(i, column_index) && 0 == frame.at<unsigned char>(i - 1, column_index))
ring_count++;
}
cout << ring_count / 2 << endl;
return 1;
}
6 | No.6 Revision |
The ring count that I get is 70. Make sure to mark my answer as correct, if you find that it works for you. :)
Here is a cropped version of your input image, which contains only the necessary data:
Here is the code to count the rings:
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
#include <iostream>
using namespace std;
int main(void)
{
Mat frame = imread("rings_slice.png");
if (frame.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
cvtColor(frame, frame, CV_BGR2GRAY);
adaptiveThreshold(frame, frame, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 11, 2);
// Use centre column
int column_index = frame.cols / 2 - 1;
int ring_count = 0;
// Start with the second row
for (int i = 1; i < frame.rows; i++)
{
// If this pixel is white and the previous pixel is black
if (255 == frame.at<unsigned char>(i, column_index) && 0 == frame.at<unsigned char>(i - 1, column_index))
ring_count++;
}
cout << ring_count << endl;
return 1;
}
7 | No.7 Revision |
The ring count that I get is 70. Make sure to mark my answer as correct, if you find that it works for you. :)
Here is a cropped version of your input image, which contains only the necessary data:
Here is the code to count the rings:
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
#include <iostream>
using namespace std;
int main(void)
{
Mat frame = imread("rings_slice.png");
if (frame.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
cvtColor(frame, frame, CV_BGR2GRAY);
adaptiveThreshold(frame, frame, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 11, 2);
// Use centre column
int column_index = frame.cols / 2 - 1;
2;
int ring_count = 0;
// Start with the second row
for (int i = 1; i < frame.rows; i++)
{
// If this pixel is white and the previous pixel is black
if (255 == frame.at<unsigned char>(i, column_index) && 0 == frame.at<unsigned char>(i - 1, column_index))
ring_count++;
}
cout << ring_count << endl;
return 1;
}
8 | No.8 Revision |
Merry Christmas. Here's your present... The ring count that I get is 70. Make sure to mark my answer as correct, if you find that it works for you. :)
Here is a cropped version of your input image, which contains only the necessary data:
Here is the code to count the rings:
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
#include <iostream>
using namespace std;
int main(void)
{
Mat frame = imread("rings_slice.png");
if (frame.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
cvtColor(frame, frame, CV_BGR2GRAY);
adaptiveThreshold(frame, frame, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 11, 2);
// Use centre column
int column_index = frame.cols / 2;
int ring_count = 0;
// Start with the second row
for (int i = 1; i < frame.rows; i++)
{
// If this pixel is white and the previous pixel is black
if (255 == frame.at<unsigned char>(i, column_index) && 0 == frame.at<unsigned char>(i - 1, column_index))
ring_count++;
}
cout << ring_count << endl;
return 1;
}
9 | No.9 Revision |
Merry Christmas. Here's your present... The ring count that I get is 70. Make sure to mark my answer as correct, if you find that it works for you. :)
Here is a cropped version of your input image, which contains only the necessary data:
Here is the C++ code to count the rings:
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
#include <iostream>
using namespace std;
int main(void)
{
Mat frame = imread("rings_slice.png");
if (frame.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
cvtColor(frame, frame, CV_BGR2GRAY);
adaptiveThreshold(frame, frame, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 11, 2);
// Use centre column
int column_index = frame.cols / 2;
int ring_count = 0;
// Start with the second row
for (int i = 1; i < frame.rows; i++)
{
// If this pixel is white and the previous pixel is black
if (255 == frame.at<unsigned char>(i, column_index) && 0 == frame.at<unsigned char>(i - 1, column_index))
ring_count++;
}
cout << ring_count << endl;
return 1;
}
10 | No.10 Revision |
Merry Christmas. Here's your present... The ring count that I get is 70. Make sure to mark my answer as correct, if you find that it works for you. :)
Here is a cropped version of your input image, which contains only the necessary data:
Here is the C++ code to count the rings:
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
#include <iostream>
using namespace std;
int main(void)
{
Mat frame = imread("rings_slice.png");
if (frame.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
cvtColor(frame, frame, CV_BGR2GRAY);
adaptiveThreshold(frame, frame, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 11, 2);
// Use centre column
int column_index = frame.cols / 2;
int ring_count = 0;
// Start with the second row
for (int i = 1; i < frame.rows; i++)
{
// If this pixel is white and the previous pixel is black
if (255 == frame.at<unsigned char>(i, column_index) && 0 == frame.at<unsigned char>(i - 1, column_index))
ring_count++;
}
cout << ring_count << endl;
return 1;
}
Alternatively, here is the Python code:
import numpy as np
import cv2
import sys
frame = cv2.imread("rings_slice.png")
if frame is None:
print('Error loading image')
exit()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
frame = cv2.adaptiveThreshold(frame, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11, 2)
rows = frame.shape[0]
cols = frame.shape[1]
column_index = cols / 2 - 1;
ring_count = 0;
# Start with the second row
for i in range(1, rows): # (int i = 1; i < rows; i++)
# If this pixel is white and the previous pixel is black
if 255 == frame[i, column_index] and 0 == frame[i - 1, column_index]:
ring_count += 1;
print ring_count
11 | No.11 Revision |
Merry Christmas. Here's your present... The ring count that I get is 70. Make sure to mark my answer as correct, if you find that it works for you. :)
Here is a cropped version of your input image, which contains only the necessary data:
Here is the C++ code to count the rings:
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
#include <iostream>
using namespace std;
int main(void)
{
Mat frame = imread("rings_slice.png");
if (frame.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
cvtColor(frame, frame, CV_BGR2GRAY);
adaptiveThreshold(frame, frame, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 11, 2);
// Use centre column
int column_index = frame.cols / 2;
int ring_count = 0;
// Start with the second row
for (int i = 1; i < frame.rows; i++)
{
// If this pixel is white and the previous pixel is black
if (255 == frame.at<unsigned char>(i, column_index) && 0 == frame.at<unsigned char>(i - 1, column_index))
ring_count++;
}
cout << ring_count << endl;
return 1;
}
Alternatively, here is the Python code:
import numpy as np
import cv2
import sys
frame = cv2.imread("rings_slice.png")
if frame is None:
print('Error loading image')
exit()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
frame = cv2.adaptiveThreshold(frame, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11, 2)
rows = frame.shape[0]
cols = frame.shape[1]
column_index = cols / 2 - 1;
ring_count = 0;
# Start with the second row
for i in range(1, rows): # (int i = 1; i < rows; i++)
# If this pixel is white and the previous pixel is black
if 255 == frame[i, column_index] and 0 == frame[i - 1, column_index]:
ring_count += 1;
print ring_count
12 | No.12 Revision |
Merry Christmas. Here's your present... The ring count that I get is 70. Make sure to mark my answer as correct, if you find that it works for you. :)
Here is a cropped version of your input image, which contains only the necessary data:
Here is the C++ code to count the rings:
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
#include <iostream>
using namespace std;
int main(void)
{
Mat frame = imread("rings_slice.png");
if (frame.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
cvtColor(frame, frame, CV_BGR2GRAY);
adaptiveThreshold(frame, frame, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 11, 2);
// Use centre column
int column_index = frame.cols / 2;
int ring_count = 0;
// Start with the second row
for (int i = 1; i < frame.rows; i++)
{
// If this pixel is white and the previous pixel is black
if (255 == frame.at<unsigned char>(i, column_index) && 0 == frame.at<unsigned char>(i - 1, column_index))
ring_count++;
}
cout << ring_count << endl;
return 1;
}
Alternatively, here is the Python code:
import numpy as np
import cv2
import sys
frame = cv2.imread("rings_slice.png")
if frame is None:
print('Error loading image')
exit()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
frame = cv2.adaptiveThreshold(frame, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11, 2)
rows = frame.shape[0]
cols = frame.shape[1]
column_index = cols / 2 - 1;
2
ring_count = 0;
# Start with the second row
for i in range(1, rows): # (int i = 1; i < rows; i++)
# If this pixel is white and the previous pixel is black
if 255 == frame[i, column_index] and 0 == frame[i - 1, column_index]:
ring_count += 1;
print ring_count
13 | No.13 Revision |
Merry Christmas. Here's your present... The ring count that I get is 70. Make sure to mark my answer as correct, if you find that it works for you. :)
Here is a cropped version of your input image, which contains only the necessary data:
Here is the C++ code to count the rings:
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
#include <iostream>
using namespace std;
int main(void)
{
Mat frame = imread("rings_slice.png");
if (frame.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
cvtColor(frame, frame, CV_BGR2GRAY);
adaptiveThreshold(frame, frame, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 11, 2);
// Use centre column
int column_index = frame.cols / 2;
int ring_count = 0;
// Start with the second row
for (int i = 1; i < frame.rows; i++)
{
// If this pixel is white and the previous pixel is black
if (255 == frame.at<unsigned char>(i, column_index) && 0 == frame.at<unsigned char>(i - 1, column_index))
ring_count++;
}
cout << ring_count << endl;
return 1;
}
Alternatively, here is the Python code:
import numpy as np
import cv2
import sys
frame = cv2.imread("rings_slice.png")
if frame is None:
print('Error loading image')
exit()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
frame = cv2.adaptiveThreshold(frame, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11, 2)
rows = frame.shape[0]
cols = frame.shape[1]
column_index = cols / 2
ring_count = 0;
# Start with the second row
for i in range(1, rows): # (int i = 1; i < rows; i++)
rows):
# If this pixel is white and the previous pixel is black
if 255 == frame[i, column_index] and 0 == frame[i - 1, column_index]:
ring_count += 1;
print ring_count
14 | No.14 Revision |
Merry Christmas. Here's your present... The ring count that I get is 70. Make sure to mark my answer as correct, if you find that it works for you. :)
Here is a cropped version of your input image, which contains only the necessary data:
Here is the C++ code to count the rings:
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
#include <iostream>
using namespace std;
int main(void)
{
Mat frame = imread("rings_slice.png");
if (frame.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
cvtColor(frame, frame, CV_BGR2GRAY);
adaptiveThreshold(frame, frame, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 11, 2);
// Use centre column
int column_index = frame.cols / 2;
int ring_count = 0;
// Start with the second row
for (int i = 1; i < frame.rows; i++)
{
// If this pixel is white and the previous pixel is black
if (255 == frame.at<unsigned char>(i, column_index) && 0 == frame.at<unsigned char>(i - 1, column_index))
ring_count++;
}
cout << ring_count << endl;
return 1;
}
Alternatively, here is the Python code:
import numpy as np
import cv2
import sys
frame = cv2.imread("rings_slice.png")
if frame is None:
print('Error loading image')
exit()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
frame = cv2.adaptiveThreshold(frame, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11, 2)
rows = frame.shape[0]
cols = frame.shape[1]
# Use centre column
column_index = cols / 2
ring_count = 0;
# Start with the second row
for i in range(1, rows):
# If this pixel is white and the previous pixel is black
if 255 == frame[i, column_index] and 0 == frame[i - 1, column_index]:
ring_count += 1;
print ring_count