Image processing using knn
Show older comments
I have 3 images that I have to label using the knn algorithm and another 18 images that i know. I don't know how to label those 18 img using a variable 18x1 named etichete and don't know how to classificate them using the knn. ext_auto is the function for maximum contrast extension. And it doesn't show hist1,hist2, hist3.
- maximum contrast extension, adaptive variant
- histogram calculation
- patient identification using the algorithm for classifying the closest k-neighbors (k-nearest neighbor - knn), the comparison will be made at the histogram level.
img1 = imread('img34.png');
img2 = imread('img35.png');
img3 = imread('img36.png');
img1 = ext_auto(img1,1);
img2 = ext_auto(img2,1);
img3 = ext_auto(img3,1);
hist1 = histogram(img1,'Normalization','probability');
hist2 = histogram(img2,'Normalization','probability');
hist3 = histogram(img3,'Normalization','probability');
figure,
subplot(2,3,1), imshow(hist1);
subplot(2,3,2), imshow(hist2);
subplot(2,3,3), imshow(hist3);
locatie = 'C:\Users\User\Desktop\Facultate\Anul III\Semestrul II\tsim\Tema2\antrenare';
files=dir(fullfile(locatie, '*.png'));
load('etichete.mat');
h = zeros(length(files),256);
for i = 1:length(files)
FileName = fullfile(locatie, files(i).name);
img = imread(FileName);
img = ext_auto(img,1);
hist = histogram(img,'Normalization','probability');
figure(i), imhist(img);
end
Accepted Answer
More Answers (0)
Categories
Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!