How can I check the continuity of a image by using code matlab
2 views (last 30 days)
Show older comments
Hi everyone, I have 2 image. The first: http://i1227.photobucket.com/albums/ee429/dqthobk89/nhp19.jpg And the second image: http://i1227.photobucket.com/albums/ee429/dqthobk89/3.jpg
I assume that I call:
- The first picture name "continuous picture" because its pixels 's colors are changing very slowly in the picture's area that I am considering.
- The second picture name "noncontinuous picture" because its pixels 's colors are changing very fast in the picture's area that I am considering.
And the question is:
Which algorithms in MATLAB that can help me discover the "noncontinuous picture" with the feature above ???
Accepted Answer
Image Analyst
on 13 Sep 2012
Are you specifically looking for a straight vertical line? Because that would make it a lot easier. Just looking for highly variable areas anywhere would yield lots of areas for some images with a lot of sharp, hard edges, say for example a photo of your office. But if we know to look for a long straight dividing line, then that's something that can be detected.
3 Comments
Image Analyst
on 16 Sep 2012
I don't have time to develop it anymore, but here's what I got so far. You'll need to finish it and experiment around with the parameters.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
format longg;
format compact;
fontSize = 20;
% Read in a demo image.
folder = 'C:\Users\Mark\Documents\Temporary';
baseFileName = 'beach3.jpg';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% File doesn't exist -- didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
% Convert to grayscale.
grayImage = rgb2gray(rgbImage);
% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows columns numberOfColorBands] = size(grayImage);
% Display the original gray scale image.
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Give a name to the title bar.
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
differenceImage = conv2(single(grayImage), [-1 1], 'same');
% Display the image.
subplot(2, 2, 2);
imshow(differenceImage, []);
title('Difference Image', 'FontSize', fontSize);
% Take absolute value
differenceImage = abs(differenceImage);
% Threshold
binaryImage = differenceImage > 15;
% Get rid of small dots of noise.
binaryImage = bwareaopen(binaryImage, 15);
% Display the image.
subplot(2, 2, 3);
imshow(binaryImage, []);
title('Big Differences Image', 'FontSize', fontSize);
labeledImage = bwlabel(binaryImage);
coloredLabels = label2rgb (labeledImage, 'hsv', 'k', 'shuffle'); % pseudo random color labels
imshow(coloredLabels, []);
% Make measurements.
measurements = regionprops(labeledImage, ...
'Area', 'Perimeter', 'Eccentricity', 'Solidity');
allAreas = [measurements.Area];
allPerimeters = [measurements.Perimeter];
circularities = allPerimeters.^2 ./ (4*pi*allAreas)
allEccentricities = [measurements.Eccentricity]
allSolidities = [measurements.Solidity]
max(allEccentricities)
allowableIndexes = circularities > 11 & allSolidities > .3; % Take the small objects.
keeperIndexes = find(allowableIndexes);
% Extract only those blobs that meet our criteria, and
% eliminate those blobs that don't meet our criteria.
% Note how we use ismember() to do this.
keeperBlobsImage = ismember(labeledImage, keeperIndexes);
% Re-label with only the keeper blobs kept.
binaryImage = bwlabel(keeperBlobsImage, 8); % Label each blob so we can make measurements of it
% Now we're done. We have a labeled image of blobs that meet our specified criteria.
subplot(2, 2, 4);
imshow(binaryImage, []);
title('"Keeper" blobs (long, skinny)');
% Now use RANSAC (see wikipedia).
More Answers (1)
See Also
Categories
Find more on Geometric Transformation and Image Registration 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!