I am doing a peanut colour sorting project?can anybody help me with the code.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Aatheeswaran M
am 11 Okt. 2018
Beantwortet: DGM
am 12 Feb. 2023
I have a rough code, but now I need to scan each row of the image and find HSV .please can anybody help me with the code.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 11 Okt. 2018
for row_number = 1 : size(YourRGBImage, 1)
hsv_of_row = rgb2hsv( YourRGBImage(row_number, :, :));
%now what?
end
Weitere Antworten (4)
Image Analyst
am 11 Okt. 2018
Please attach your rough code. Also, is this an school assignment for you? http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
You might also look into rgb2ind() to do a rough labeling of your different color regions. Once they're labeled you can then convert the image to HSV and then use regionprops to get the HSV of each region.
2 Kommentare
Image Analyst
am 12 Okt. 2018
Bearbeitet: Image Analyst
am 12 Okt. 2018
You've accepted an answer so I assume the above comment does not apply anymore.
If you still don't have a solution then attach your image.
See my Delta E tutorial in my File Exchange https://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc
Image Analyst
am 12 Okt. 2018
Alright, Aatheeswaran, since you won't post your image I had to make a guess at what one would look like to give you a full demo. Run the attached m-file
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/197755/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/197761/image.png)
7 Kommentare
Image Analyst
am 26 Okt. 2018
Verschoben: DGM
am 12 Feb. 2023
You should really consult a professional to get an imaging system that will get you images that can be analyzed. No professional industrial system would make images like
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/193516/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/193518/image.jpeg)
when you could set up a system with much, MUCH better image capture characteristics. I mean if we came up with an algorithm to handle those two types of images, then you'd just come along with some third and fourth type of image where the algorithm doesn't work on. So there is no sense in trying to solve this type of scenario now, not until you can get good images. Best would be uniform lighting, with a Color Checker chart in the field of view, uniform focus, top down (not an oblique angle), high depth of field, telecentric lens, etc. I design imaging systems all the time - you really need to get professional help. It's SO much easier to create an algorithm to work with a great image than so spend months perfecting an algorithm to handle crummy, variable images - something that just wouldn't be necessary if you had great images to start with.
bhadra j
am 8 Feb. 2019
hi all,
I am mtech student and i want to develp a matlab code to sort bad nuts.can anybody help me with the code in sorting this white peanut from the good one. i saw the above programes but could not sort them. iam new to matlab so can anybody guide me how to sort them .
i have attached two images with two background.
0 Kommentare
DGM
am 12 Feb. 2023
I have this demo I made for finding bad peanuts. I hope someone finds it helpful.
% read the peanut image
inpict = imread('peanuts.png');
% use color-based thresholding to isolate peanuts from background
labpict = rgb2lab(inpict);
th = [54.57 100; 22.82 53; 22.10 74.46];
th = permute(th,[3 2 1]);
mask = all((labpict >= th(1,1,:)) & (labpict <= th(1,2,:)),3);
% remove extraneous blobs from mask
mask = imfill(mask,'holes');
mask = bwareaopen(mask,2000);
% get object properties
S = regionprops(mask,'centroid');
% plot results
imshow(inpict); hold on
title('Location of Bad Peanuts')
for k = 1:numel(S)
hp = plot(S(k).Centroid(1),S(k).Centroid(2),'bx');
hp.MarkerSize = 20;
hp.LineWidth = 3;
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Convert Image Type finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!