필터 지우기
필터 지우기

Why the output image is not visible after k means clustering ?

조회 수: 1 (최근 30일)
MINO GEORGE
MINO GEORGE 2021년 8월 31일
댓글: MINO GEORGE 2021년 9월 3일
Here is the code,
img_folder='C:\Users\COMSOL\Documents\MATLAB\kss';
fname = dir(fullfile(img_folder,'*.jpg'))
grayImage= imread('calculi-140.jpg');
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels == 3
fprintf('That was a color image. I am converting it to grayscale.\n');
grayImage = rgb2gray(grayImage);
end
grayImage = imgaussfilt(grayImage);
gr= imadjust(grayImage,stretchlim(grayImage),[]);
features = extractLBPFeatures(gr);
numberOfClasses = 3; %k means clustering
indexes = kmeans(features(:), numberOfClasses);
classImage = reshape(indexes, size(features));
figure, imshow(classImage);
I am getting a white linea as the output
The input and output images are attached. Pls check and help me to solve this error. Any help is appreciated.
  댓글 수: 1
KSSV
KSSV 2021년 8월 31일
It is because, you are inputting an array into kmeans.
features = extractLBPFeatures(gr);
Check features, this is 1X59 array.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sahil Jain
Sahil Jain 2021년 9월 3일
Hi. As mentioned by another community member, the "extractLBPFeatures" function returns a vector of features which is why the output of your k-means is also a vector. To not have the output as a white line, you can try using "imshow(classImage, [])". This will display the minimum value of "classImage" as black and the maximum value as white.
  댓글 수: 1
MINO GEORGE
MINO GEORGE 2021년 9월 3일
Thank you for your reply sir. I tried imshow(classImage, []), there is no change in the output. I have attached the new output image.

댓글을 달려면 로그인하십시오.

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by