How to plot a pizza bar with my colors found?
Show older comments
I want plot a pizza bar with my colors found, How can I do this?
This is my code:
%%*** [DADOS DO AUTOR] *** %%
%{
% Developed by: Marlon Vieira Damaceno
% email: marlonfaint@hotmail.com
% Faculdade de Tecnologia SENAI Porto Alegre 2017/2.
% Tecnólogo em Sistemas Embarcados.
% TCC - Análise Dermatológica Utilizando Técnicas de Processamento de Imagens.
% Analisa a imagem e atribui uma nota (0 - 6).
% Em funcao da presenca das cores: Marron claro, marron escuro, vermelho, azul, preto e branco.
% Rotina aplicada a analise de lesoes de pele - criterio da Regra ABCD.
% Marlon Vieira Damaceno e [Alexandre Haupt]
% Data: 14/11/2017.
% *** [COLOR FUNCTION] *** %
function [C] = COLORDETECT
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 14;
rgbImage = imread('MELANOMA.jpg'); %ler a imagem
%%[EXTRACT THE INDIVIDUAL RED, GREEN, AND BLUE COLOR CHANNELS]
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
subplot(2,2,1);
imshow(rgbImage, 'DisplayRange',[]), colorbar;
title('Original RGB Image ', 'FontSize', fontSize);
subplot(2,2,2);
imshow(redChannel, 'DisplayRange',[]), colorbar;
title('Image Red', 'FontSize', fontSize);
subplot(2,2,3);
imshow(greenChannel, 'DisplayRange',[]), colorbar;
title('Image Green', 'FontSize', fontSize);
subplot(2,2,4);
imshow(blueChannel, 'DisplayRange',[]), colorbar;
title('Image Blue', 'FontSize', fontSize);
%%***CODE BAR PIZZA***%%
%%[FIND THE DARK BROWN PIXELS ON THE 3 CHANNELS]
darkbrownPixels = (redChannel > 109 & redChannel < 115) & (greenChannel > 78 & greenChannel < 82) & (blueChannel > 64 & blueChannel < 68);
%DARKBROWN = [ R=115 | G=82 | B=68 ] - faixa de erro definida pelo autor (5%)
numdarkbrown = sum(darkbrownPixels(:) == 1);
if (numdarkbrown > 0)
numdarkbrown = 1;
end
numdarkbrown
%%[FIND THE LIGHT BROWN PIXELS ON THE 3 CHANNELS]
lightbrownPixels = (redChannel > 188 & redChannel < 194) & (greenChannel > 142 & greenChannel < 150) & (blueChannel > 123 & blueChannel < 130);
%LIGHTBROWN = [ R=194 | G=150 | B=130 ] - faixa de erro definida pelo autor (5%)
numlightbrown = sum(lightbrownPixels(:) == 1);
if (numlightbrown > 0)
numlightbrown = 1;
end
numlightbrown
%%[FIND THE WHITE PIXELS ON THE 3 CHANNELS]
whitePixels = (redChannel > 243 & redChannel < 255) & (greenChannel > 243 & greenChannel < 255) & (blueChannel > 242 & blueChannel < 255);
%WHITE = [ R=243 | G=243 | B=242 ] - faixa de erro definida pelo autor (5%)
numwhite = sum(whitePixels(:) == 1);
if (numwhite > 0)
numwhite = 1;
end
numwhite
%%[FIND THE BLACK PIXELS ON THE 3 CHANNELS]
blackPixels = (redChannel > 0 & redChannel < 52) & (greenChannel > 0 & greenChannel < 52) & (blueChannel > 0 & blueChannel < 52);
%BLACK = [ R=52 | G=52 | B=52 ] - faixa de erro definida pelo autor (5%)
numblack = sum(blackPixels(:) == 1);
if (numblack > 0)
numblack = 1;
end
numblack
%%[FIND THE BLUE PIXELS ON THE 3 CHANNELS]
bluePixels = (redChannel > 0 & redChannel < 56) & (greenChannel > 0 & greenChannel < 61) & (blueChannel > 150 & blueChannel < 255);
%BLUE = [ R=56 | G=61 | B=150 ] - faixa de erro definida pelo autor (5%)
numblue = sum(bluePixels(:) == 1);
if (numblue > 0)
numblue = 1;
end
numblue
%%[FIND THE RED PIXELS ON THE 3 CHANNELS]
redPixels = (redChannel > 175 & redChannel < 255) & (greenChannel > 0 & greenChannel < 54) & (blueChannel > 0 & blueChannel < 60);
%RED = [ R=175 | G=54 | B=60 ] - faixa de erro definida pelo autor (5%)
numred = sum(redPixels(:) == 1);
if (numred > 0)
numred = 1;
end
numred
%%[SUM OF ALL COLORS DETECTED]
numcolor = numlightbrown + numdarkbrown + numwhite + numblack + numblue + numred;
numcolor
c = categorical({'DarkBrown','LightBrown','White','Black','Red','Blue'});
values = [numdarkbrown numlightbrown numwhite numblack numred numblue];
%bar(c, values)
end
2 Comments
Walter Roberson
on 21 Nov 2017
What is a "pizza bar" in this context? Is that a "pie chart" ?
Marlon Damaceno
on 21 Nov 2017
Edited: Marlon Damaceno
on 21 Nov 2017
Accepted Answer
More Answers (0)
Categories
Find more on Red in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!