Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

Color Image Segregation using ResNet-18 & K-Means Clustering

Dataset: ------------ https://github.com/SatadruMukherjee/D... Code:


clc;

clear all;

close all;

warning off;

net=resnet18;

layers=net.Layers;

featureLayer='pool5';

imds=imageDatastore('pets');

inputSize = net.Layers(1).InputSize;

augimdsTrain = augmentedImageDatastore(inputSize(1:2),imds);

featuresTrain = activations(net,augimdsTrain,featureLayer,'OutputAs','rows');

ms=kmeans(featuresTrain,2,'Replicate',5);

pathname_a='C:\Users\USER\Desktop\a\';

pathname_b='C:\Users\USER\Desktop\b\';

temp=1;

gemp=1;

for i=1:numel(imds.Files)

    img=readimage(imds,i);

    if(ms(i)==1)

        filename=strcat(num2str(temp),'.bmp');

        imwrite(img,strcat(pathname_a,filename));

        temp=temp+1;

    else

        filename=strcat(num2str(gemp),'.bmp');

        imwrite(img,strcat(pathname_b,filename));

        gemp=gemp+1;

    end

end

 

 


Join us on Telegram: https://t.me/matlabcastor

No comments

Popular Posts

Followers