How to use a naive bayes classifier with this data?

1 view (last 30 days)
i would like to use a naive bayes classifier to reconstruct an image based on the probabilities calculated within the code below. from what I've gathered i need to fit the probabilities to training data? i just am not sure how to do this. if anyone could point me in the right direction i would greatly appreciate it.
RGB=imread(input('image name\n'));
[indexed,map]= rgb2ind(RGB,8);
imwrite(indexed,map,input('What would you like to save the new image as?\n'));
[numrows, numcolumns]=size(indexed);
dims=numrows*numcolumns;
probability=imhist(indexed,map)./dims
row=1;
column=1;
row_prob=[];
col_prob=[];
row_value=[];
col_value=[];
counter=0;
final_prob_row=[];
final_prob_col=[];
while column<=numcolumns && row<=numrows && counter<=7
col_prob=sum(indexed(:,column)==counter);
row_prob=sum(indexed(row,:)==counter);
col_value=[col_value col_prob];
row_value=[row_value row_prob];
if column == numcolumns
final_prob_row = [final_prob_row;row_value];
final_prob_col = [final_prob_col;col_value];
column=0;
row=0;
counter=counter+1;
col_value=[];
row_value=[];
end
column=column+1;
row=row+1;
end
final_final_prob_row=final_prob_row./numrows
final_final_prob_col=final_prob_col./numcolumns
if i have been to vague or left something out feel free to tell me

Answers (0)

Community Treasure Hunt

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

Start Hunting!