Skip to main content
Code Review

Return to Question

deleted 36 characters in body
Source Link
dogac
  • 33
  • 6

I'm new learning python and image processing with python. For this reason, I took a project called "Classification of breast cancer images with deep learning".

I applied the following techniques: 1)Threshold, 2)K-Means

import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread('n001.tif', 0)
_, blackAndWhite = cv2.threshold(img, 100, 255, cv2.THRESH_BINARY_INV)
nlabels, labels, stats, centroids = cv2.connectedComponentsWithStats(blackAndWhite, None, None, None, 8, cv2.CV_32S)
sizes = stats[1:, -1] #get CC_STAT_AREA component
img2 = np.zeros((labels.shape), np.uint8)
for i in range(0, nlabels - 1):
 if sizes[i] >= 100: #filter small dotted regions
 img2[labels == i + 1] = 255
res = cv2.bitwise_not(img2)
cv2.imwrite('n001New.tif', res)
########################################################################
img = cv2.cvtColor(res, cv2.COLOR_BGR2RGB)
 
Z = img.reshape((-1,3))
Z = np.float32(Z)
 
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 250 , 1.0)
 
K=2
ret, label, center= cv2.kmeans(Z, K, None, criteria, 250, 
 cv2.KMEANS_RANDOM_CENTERS)
center = np.uint8(center)
res = center[label.flatten()]
output = res.reshape((img.shape))
plt.imshow(output)
plt.show()

Data set consists of tif extension image: benign, inSitu, invasive and normal Input images

Output images:Output images

I have a few questions:

  1. Are my methods correct?
  2. Are the outputs correct? Do I find the right areas?
  3. Did I use the K-Means algorithm correctly? Which values ​​will I send to cnn?

I would appreciate it if you could answer the questions above.

I'm new learning python and image processing with python. For this reason, I took a project called "Classification of breast cancer images with deep learning".

I applied the following techniques: 1)Threshold, 2)K-Means

import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread('n001.tif', 0)
_, blackAndWhite = cv2.threshold(img, 100, 255, cv2.THRESH_BINARY_INV)
nlabels, labels, stats, centroids = cv2.connectedComponentsWithStats(blackAndWhite, None, None, None, 8, cv2.CV_32S)
sizes = stats[1:, -1] #get CC_STAT_AREA component
img2 = np.zeros((labels.shape), np.uint8)
for i in range(0, nlabels - 1):
 if sizes[i] >= 100: #filter small dotted regions
 img2[labels == i + 1] = 255
res = cv2.bitwise_not(img2)
cv2.imwrite('n001New.tif', res)
########################################################################
img = cv2.cvtColor(res, cv2.COLOR_BGR2RGB)
 
Z = img.reshape((-1,3))
Z = np.float32(Z)
 
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 250 , 1.0)
 
K=2
ret, label, center= cv2.kmeans(Z, K, None, criteria, 250, 
 cv2.KMEANS_RANDOM_CENTERS)
center = np.uint8(center)
res = center[label.flatten()]
output = res.reshape((img.shape))
plt.imshow(output)
plt.show()

Data set consists of tif extension image: benign, inSitu, invasive and normal Input images

Output images:Output images

I have a few questions:

  1. Are my methods correct?
  2. Are the outputs correct? Do I find the right areas?
  3. Did I use the K-Means algorithm correctly? Which values ​​will I send to cnn?

I would appreciate it if you could answer the questions above.

I'm new learning python and image processing with python. For this reason, I took a project called "Classification of breast cancer images with deep learning".

I applied the following techniques: 1)Threshold, 2)K-Means

import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread('n001.tif', 0)
_, blackAndWhite = cv2.threshold(img, 100, 255, cv2.THRESH_BINARY_INV)
nlabels, labels, stats, centroids = cv2.connectedComponentsWithStats(blackAndWhite, None, None, None, 8, cv2.CV_32S)
sizes = stats[1:, -1] #get CC_STAT_AREA component
img2 = np.zeros((labels.shape), np.uint8)
for i in range(0, nlabels - 1):
 if sizes[i] >= 100: #filter small dotted regions
 img2[labels == i + 1] = 255
res = cv2.bitwise_not(img2)
cv2.imwrite('n001New.tif', res)
########################################################################
img = cv2.cvtColor(res, cv2.COLOR_BGR2RGB)
 
Z = img.reshape((-1,3))
Z = np.float32(Z)
 
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 250 , 1.0)
 
K=2
ret, label, center= cv2.kmeans(Z, K, None, criteria, 250, 
 cv2.KMEANS_RANDOM_CENTERS)
center = np.uint8(center)
res = center[label.flatten()]
output = res.reshape((img.shape))
plt.imshow(output)
plt.show()

Data set consists of tif extension image: benign, inSitu, invasive and normal Input images

Output images:Output images

I have a few questions:

  1. Are my methods correct?
  2. Are the outputs correct? Do I find the right areas?
  3. Did I use the K-Means algorithm correctly?

I would appreciate it if you could answer the questions above.

added 1 character in body
Source Link
dogac
  • 33
  • 6

I'm new learning python and image processing with python. For this reason, I took a project called "Classification of breast cancer images with deep learning".

I applied the following techniques: 1)Threshold, 2)K-Means

import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread('n001.tif', 0)
_, blackAndWhite = cv2.threshold(img, 100, 255, cv2.THRESH_BINARY_INV)
nlabels, labels, stats, centroids = cv2.connectedComponentsWithStats(blackAndWhite, None, None, None, 8, cv2.CV_32S)
sizes = stats[1:, -1] #get CC_STAT_AREA component
img2 = np.zeros((labels.shape), np.uint8)
for i in range(0, nlabels - 1):
 if sizes[i] >= 100: #filter small dotted regions
 img2[labels == i + 1] = 255
res = cv2.bitwise_not(img2)
cv2.imwrite('n001New.tif', res)
########################################################################
img = cv2.cvtColor(res, cv2.COLOR_BGR2RGB)
 
Z = img.reshape((-1,3))
Z = np.float32(Z)
 
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 250 , 1.0)
 
K=2
ret, label, center= cv2.kmeans(Z, K, None, criteria, 250, 
 cv2.KMEANS_RANDOM_CENTERS)
center = np.uint8(center)
res = center[label.flatten()]
output = res.reshape((img.shape))
plt.imshow(output)
plt.show()

Data set consists of tif extension image: benign, inSitu, invasive and normal Input images

Output images:Output images

I have a few questions:

  1. Are my methods correct?
  2. Are the outputs correct? Do I find the right areas?
  3. Did I use the K-Means algorithm correctly? WhatWhich values ​​will I send to cnn?

I would appreciate it if you could answer the questions above.

I'm new learning python and image processing with python. For this reason, I took a project called "Classification of breast cancer images with deep learning".

I applied the following techniques: 1)Threshold, 2)K-Means

import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread('n001.tif', 0)
_, blackAndWhite = cv2.threshold(img, 100, 255, cv2.THRESH_BINARY_INV)
nlabels, labels, stats, centroids = cv2.connectedComponentsWithStats(blackAndWhite, None, None, None, 8, cv2.CV_32S)
sizes = stats[1:, -1] #get CC_STAT_AREA component
img2 = np.zeros((labels.shape), np.uint8)
for i in range(0, nlabels - 1):
 if sizes[i] >= 100: #filter small dotted regions
 img2[labels == i + 1] = 255
res = cv2.bitwise_not(img2)
cv2.imwrite('n001New.tif', res)
########################################################################
img = cv2.cvtColor(res, cv2.COLOR_BGR2RGB)
 
Z = img.reshape((-1,3))
Z = np.float32(Z)
 
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 250 , 1.0)
 
K=2
ret, label, center= cv2.kmeans(Z, K, None, criteria, 250, 
 cv2.KMEANS_RANDOM_CENTERS)
center = np.uint8(center)
res = center[label.flatten()]
output = res.reshape((img.shape))
plt.imshow(output)
plt.show()

Data set consists of tif extension image: benign, inSitu, invasive and normal Input images

Output images:Output images

I have a few questions:

  1. Are my methods correct?
  2. Are the outputs correct? Do I find the right areas?
  3. Did I use the K-Means algorithm correctly? What values ​​will I send to cnn?

I would appreciate it if you could answer the questions above.

I'm new learning python and image processing with python. For this reason, I took a project called "Classification of breast cancer images with deep learning".

I applied the following techniques: 1)Threshold, 2)K-Means

import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread('n001.tif', 0)
_, blackAndWhite = cv2.threshold(img, 100, 255, cv2.THRESH_BINARY_INV)
nlabels, labels, stats, centroids = cv2.connectedComponentsWithStats(blackAndWhite, None, None, None, 8, cv2.CV_32S)
sizes = stats[1:, -1] #get CC_STAT_AREA component
img2 = np.zeros((labels.shape), np.uint8)
for i in range(0, nlabels - 1):
 if sizes[i] >= 100: #filter small dotted regions
 img2[labels == i + 1] = 255
res = cv2.bitwise_not(img2)
cv2.imwrite('n001New.tif', res)
########################################################################
img = cv2.cvtColor(res, cv2.COLOR_BGR2RGB)
 
Z = img.reshape((-1,3))
Z = np.float32(Z)
 
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 250 , 1.0)
 
K=2
ret, label, center= cv2.kmeans(Z, K, None, criteria, 250, 
 cv2.KMEANS_RANDOM_CENTERS)
center = np.uint8(center)
res = center[label.flatten()]
output = res.reshape((img.shape))
plt.imshow(output)
plt.show()

Data set consists of tif extension image: benign, inSitu, invasive and normal Input images

Output images:Output images

I have a few questions:

  1. Are my methods correct?
  2. Are the outputs correct? Do I find the right areas?
  3. Did I use the K-Means algorithm correctly? Which values ​​will I send to cnn?

I would appreciate it if you could answer the questions above.

added 100 characters in body
Source Link
dogac
  • 33
  • 6

I'm new learning python and image processing with python. For this reason, I took a project called "Classification of breast cancer images with deep learning".

I applied the following techniques: 1)Threshold, 2)K-Means

import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread('n001.tif', 0)
_, blackAndWhite = cv2.threshold(img, 100, 255, cv2.THRESH_BINARY_INV)
nlabels, labels, stats, centroids = cv2.connectedComponentsWithStats(blackAndWhite, None, None, None, 8, cv2.CV_32S)
sizes = stats[1:, -1] #get CC_STAT_AREA component
img2 = np.zeros((labels.shape), np.uint8)
for i in range(0, nlabels - 1):
 if sizes[i] >= 100: #filter small dotted regions
 img2[labels == i + 1] = 255
res = cv2.bitwise_not(img2)
cv2.imwrite('n001New.tif', res)
########################################################################
img = cv2.cvtColor(res, cv2.COLOR_BGR2RGB)
 
Z = img.reshape((-1,3))
Z = np.float32(Z)
 
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 250 , 1.0)
 
K=2
ret, label, center= cv2.kmeans(Z, K, None, criteria, 250, 
 cv2.KMEANS_RANDOM_CENTERS)
center = np.uint8(center)
res = center[label.flatten()]
output = res.reshape((img.shape))
plt.imshow(output)
plt.show()

Data set consists of tif extension image: benign, inSitu, invasive and normal Input images

Output images:Output images

I have a few questions:

  1. Are my methods correct?
  2. Are the outputs correct? Do I find the right areas?
  3. Did I use the K-Means algorithm correctly? What values ​​will I send to cnn?

I would appreciate it if you could answer the questions above.

I'm new learning python and image processing with python. For this reason, I took a project called "Classification of breast cancer images with deep learning".

I applied the following techniques: 1)Threshold, 2)K-Means

import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread('n001.tif', 0)
_, blackAndWhite = cv2.threshold(img, 100, 255, cv2.THRESH_BINARY_INV)
nlabels, labels, stats, centroids = cv2.connectedComponentsWithStats(blackAndWhite, None, None, None, 8, cv2.CV_32S)
sizes = stats[1:, -1] #get CC_STAT_AREA component
img2 = np.zeros((labels.shape), np.uint8)
for i in range(0, nlabels - 1):
 if sizes[i] >= 100: #filter small dotted regions
 img2[labels == i + 1] = 255
res = cv2.bitwise_not(img2)
cv2.imwrite('n001New.tif', res)
########################################################################
img = cv2.cvtColor(res, cv2.COLOR_BGR2RGB)
 
Z = img.reshape((-1,3))
Z = np.float32(Z)
 
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 250 , 1.0)
 
K=2
ret, label, center= cv2.kmeans(Z, K, None, criteria, 250, 
 cv2.KMEANS_RANDOM_CENTERS)
center = np.uint8(center)
res = center[label.flatten()]
output = res.reshape((img.shape))
plt.imshow(output)
plt.show()

Data set consists of tif extension image: benign, inSitu, invasive and normal Input images

Output images:Output images

I have a few questions:

  1. Are my methods correct?
  2. Are the outputs correct? Do I find the right areas?
  3. Did I use the K-Means algorithm correctly?

I'm new learning python and image processing with python. For this reason, I took a project called "Classification of breast cancer images with deep learning".

I applied the following techniques: 1)Threshold, 2)K-Means

import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread('n001.tif', 0)
_, blackAndWhite = cv2.threshold(img, 100, 255, cv2.THRESH_BINARY_INV)
nlabels, labels, stats, centroids = cv2.connectedComponentsWithStats(blackAndWhite, None, None, None, 8, cv2.CV_32S)
sizes = stats[1:, -1] #get CC_STAT_AREA component
img2 = np.zeros((labels.shape), np.uint8)
for i in range(0, nlabels - 1):
 if sizes[i] >= 100: #filter small dotted regions
 img2[labels == i + 1] = 255
res = cv2.bitwise_not(img2)
cv2.imwrite('n001New.tif', res)
########################################################################
img = cv2.cvtColor(res, cv2.COLOR_BGR2RGB)
 
Z = img.reshape((-1,3))
Z = np.float32(Z)
 
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 250 , 1.0)
 
K=2
ret, label, center= cv2.kmeans(Z, K, None, criteria, 250, 
 cv2.KMEANS_RANDOM_CENTERS)
center = np.uint8(center)
res = center[label.flatten()]
output = res.reshape((img.shape))
plt.imshow(output)
plt.show()

Data set consists of tif extension image: benign, inSitu, invasive and normal Input images

Output images:Output images

I have a few questions:

  1. Are my methods correct?
  2. Are the outputs correct? Do I find the right areas?
  3. Did I use the K-Means algorithm correctly? What values ​​will I send to cnn?

I would appreciate it if you could answer the questions above.

Tweeted twitter.com/StackCodeReview/status/1088768577170276360
deleted 135 characters in body; edited tags; edited title
Source Link
200_success
  • 145.5k
  • 22
  • 190
  • 478
Loading
added 1 character in body
Source Link
dogac
  • 33
  • 6
Loading
Source Link
dogac
  • 33
  • 6
Loading
lang-py

AltStyle によって変換されたページ (->オリジナル) /