How can I check the continuity of a image by using code matlab

2 views (last 30 days)
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
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
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).
Tho
Tho on 27 Sep 2012
Edited: Image Analyst on 27 Sep 2012
I have already read your code and understood what you meant. You used "ransac" to define the "ouliers" that were not placed in the model that we had set with binary image. But when I try to search the "ransac", I know that the input of "ransac" is the matrix of 2xn. I don't understand this thing much. When I applied your code to some images, the "outliers" appear clearly, ( http://i1227.photobucket.com/albums/ee429/dqthobk89/TestFucntion2.png); but with the others, the "outlier" is not as clear as in the picture( http://i1227.photobucket.com/albums/ee429/dqthobk89/TestFucntion1.png). I think I can not check all cases of this, because when I applied it to some image of tables, chairs... there appeared many "outlier". What do you think about this?

Sign in to comment.

More Answers (1)

Greg Heath
Greg Heath on 13 Sep 2012
I always look for discontinuities by taking derivatives.
  2 Comments
Tho
Tho on 13 Sep 2012
How can you do it? because RGB image is matrix of pixels not a simple function that you can take derivatives

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!