use rgb to caculate three brown ratio
Ältere Kommentare anzeigen
sorry i say more about i want coding which can show light color, dark color, intermediate color ratio
focus is kind and ratio
image = imread('sample.jpeg');
image_double = im2double(image);
percentage_a = image_double(:,:,1) / sum(image_double, 3);
percentage_b = image_double(:,:,2) / sum(image_double, 3);
percentage_c = image_double(:,:,3) / sum(image_double, 3);
disp([num2str(percentage_a) '%']);
disp([num2str(percentage_b) '%']);
disp([num2str(percentage_c) '%']);
and picture like it ( the word we can ignore)

Akzeptierte Antwort
Weitere Antworten (2)
Hassaan
am 6 Apr. 2024
image = imread('sample.jpeg'); % Load the image
image_double = im2double(image); % Convert to double precision floating point
% Calculate the sum of RGB values across the third dimension
sum_rgb = sum(image_double, 3);
% Calculate the percentage of each RGB channel relative to the sum
percentage_r = mean(mean(image_double(:,:,1) ./ sum_rgb));
percentage_g = mean(mean(image_double(:,:,2) ./ sum_rgb));
percentage_b = mean(mean(image_double(:,:,3) ./ sum_rgb));
% Display the results
fprintf('Red Channel Percentage: %.2f%%\n', percentage_r * 100);
fprintf('Green Channel Percentage: %.2f%%\n', percentage_g * 100);
fprintf('Blue Channel Percentage: %.2f%%\n', percentage_b * 100);
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Professional Interests
- Technical Services and Consulting
- Embedded Systems | Firmware Developement | Simulations
- Electrical and Electronics Engineering
Feel free to contact me.
1 Kommentar
bozheng
am 6 Apr. 2024
Image Analyst
am 8 Apr. 2024
0 Stimmen
You could try using kmeans with k=5 for the three browns, black, and white (for the letters). Or you could also use K nearest Neighbors. Demos are attached.
Kategorien
Mehr zu Introduction to Installation and Licensing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!