Hello, I am looking for advice on image analyzing on covid strip tests in order to see if tests are positive or negative (two or one horizontal lines).

3 views (last 30 days)
Hello, I am trying to detect if an image has parallel horizontal lines using matlab (meaning test strip indicates positive). I have tried many different Matlab image functions, but have been unsuccessful thus far. An example could be processing the below image to see that the first strip has one line, the second strip has two lines, and the third strip has one line. Here is the code I have tried using thus far:
image = imread("MultiplexV1Negativetests.jpeg","jpeg");
previousimage = image;
gray_img = rgb2gray(image);
% Use global thresholding to convert the image to binary
threshold = graythresh(gray_img);
binary_img = im2bw(gray_img, threshold);
% Invert the binary image
binary_img = ~binary_img;
% Multiply the binary image with the original image to remove the background
image(repmat(~binary_img,[1 1 3])) = 0;
figure(1)
subplot(1,2,1)
imshow(previousimage)
subplot(1,2,2)
imshow(image)
B=im2gray(image);
figure(2)
imshow(B)
B2=im2double(B);
BW = edge(B2,'canny');
figure(3)
imshow(BW)
figure(4)
[H,T,R] = hough(BW);
imshow(H,[],'XData',T,'YData',R,...
'InitialMagnification','fit');
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
P = houghpeaks(H,5,'threshold',ceil(0.3*max(H(:))));
x = T(P(:,2)); y = R(P(:,1));
plot(x,y,'s','color','white');
c = numel(find(x==0))
Any advice for new functions/techniques to try to implement would be greatly appreciated. Thank you!

Answers (1)

Cris LaPierre
Cris LaPierre on 17 Jan 2024

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!