Mohammad Yakub
Mohammad Yakub

Reputation: 7

How can I detect the green region (meter display) & crop it out using MATLAB?

I want to extract the green region (meter display) from an image. Here I have attached an image which is digital electric meter. I want to extract only the region which contains the meter reading value. If I only detect the green region then other green regions are also detected, but I want to detect only the green region which contains meter reading. How can I do that in MATLAB ?

close all;
clear all;
clc;
Im = imread('2.jpg');
Im = imresize(Im, [512 512]);
diff_im = imsubtract(Im(:,:,2),rgb2gray(Im));
figure,imshow(diff_im);

Raw image

Upvotes: 0

Views: 266

Answers (1)

KjMag
KjMag

Reputation: 2780

Just binarize the result:

binary = imbinarize(diff_im, 25/255); % optimal threshold would be between 22 and 25
figure,imshow(binary);

You can also play with morphological operations afterwards, e.g. morphological opening to remove leftovers of other areas.

Upvotes: 1

Related Questions