# How do i calculate the Average of each Pixel in Origenal Image to the Average of Class to Classify each class in the Image?

1 view (last 30 days)
Amr Azab on 29 Jul 2022
Commented: Amr Azab on 30 Jul 2022
I hope somebody can help me.
I have calculated the Average of ROI but i need to know, How can i calculate the Average between each Pixel of (orph) Image and the Average that i already Calculated? to be able to Classify the Pixels for each Class.
The code written below
-------------------------------------------------------------------------------------------------------------------------------------------
% CleanUp
clc;
clear;
close all;
figure, imshow (orph,[]);
%Define Region of interest
roi_Building = drawpolygon('Color','r');
roi_street = drawline('Color','y');
roi_tree = drawfreehand('Color','g');
roi_car = drawpolygon('Color','b');
%Seperate channels RGB
op_red = orph(:,:,1); % Red channel
op_green = orph(:,:,2); % Green channel
op_blue = orph(:,:,3); % Blue channel
%Value of pixels in all layers
[r, c, ~] = size(orph);
%Buildings
[r, c, p] = size(orph); %Row, Column and layers (size of Image)
mask3_building = repmat(createMask(roi_Building, r, c), [1, 1, 3]); %Repeat copies of array
masked_building = zeros(r, c, p, 'like', orph);
%Street
masked_street = zeros(r, c, p, 'like', orph);
%Tree
masked_tree = zeros(r, c, p, 'like', orph);
%Car
masked_car = zeros(r, c, p, 'like', orph);
%Arithmetic average for each Class
%Average between every Pixel in Picture to average for each Class ??????!!!!!
for i= 1: 10000 :length (i)
for j = 1: 10000: length (j)
AVG_i= mean(i/AVG_Building);
AVG_j= mean(j/AVG_Building);
end
end Amr Azab on 29 Jul 2022
@Walter Roberson Do you have please resolving this question?

Image Analyst on 29 Jul 2022
See my attached demo. It lets you draw an outline around each color class you want, and then it assigns a class number to each pixel in the image based on your training regions and a discriminant classifier. That sounds like what you want to do. Amr Azab on 30 Jul 2022
Thank you so much

### Categories

Find more on Deep Learning for Image Processing in Help Center and File Exchange

R2021a

### Community Treasure Hunt

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

Start Hunting!