You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
getiing roi of real time image through matlab and block processing.
13 views (last 30 days)
Show older comments
satnam singh
on 20 Feb 2013
hi there, i am in great problem. can any one please tell me how to select ROI in any real time image through webcam. i am trying to get the real time image of face of the Rubik's cube. i want to select the Roi and then divide the image of the Rubik's face into nine blocks. then i want to take the mean of the pixels in the particular block,and thus identify the color in each block. please tell me how to get the boundary of the face of the Rubik on the webcam and then then divide it into blocks. it is really annoying me......please any one help me........it will be really grateful...........please help....... hoping for the solution soon.............
8 Comments
Image Analyst
on 20 Feb 2013
And where did you post your image? How can we give image analysis advice without an image???
satnam singh
on 21 Feb 2013
sir , here i have posted the real image type through webcam. ihave to do analysis of that and identify the colours in each block. . . i am just a beginner in image processing...so if possible provide me the explanation...it will be really helpful..
satnam singh
on 23 Feb 2013
plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2); ....can any one explain plese what the significane of(:,2),and(:,1) int the above function. ... ...reply please......
Accepted Answer
Image Analyst
on 21 Feb 2013
If all your images will be so nicely illuminated with bright saturated colors and "face on" views of the cube, then it should be easy. Just look over some of the color segmentation tutorials in my File Exchange.
40 Comments
satnam singh
on 23 Feb 2013
plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2); ....can any one explain plese what the significane of(:,2),and(:,1) int the above function. ... ...reply please......
Image Analyst
on 23 Feb 2013
The boundary is a N by 2 array with the rows (y values) in the first column and the columns (x values) in the second column. So the plot is like this: plot(x,y). Using : means to take all rows, and the second number is the column, so (:,1) means "all rows in the first column".
satnam singh
on 25 Feb 2013
text(blobCentroid(1) + labelShiftX, blobCentroid(2), num2str(k), 'FontSize', fontSize, 'FontWeight', 'Bold'); .. .. please explain the functioning of above function...&( blobCentroid(1) + labelShiftX)??????? num2str(k)..??????????? ......please reply soon...
Image Analyst
on 25 Feb 2013
It's just putting a label with the blob number next to the centroid of the blob.
satnam singh
on 2 Mar 2013
Edited: Walter Roberson
on 2 Mar 2013
% Set all axes to be the same width and height.
% This makes it easier to compare them.
maxGL = max([maxGLValueR, maxGLValueG, maxGLValueB]);
if eightBit
maxGL = 255;
end
maxCount = max([maxCountR, maxCountG, maxCountB]);
axis([hR hG hB], [0 maxGL 0 maxCount]);
...
...
sir please explain why...maxGL is calculated and further it is made equal to 255.......what is arguments used inside function 'asix'...in your program for red object detection..
hoping for the reply soon........
satnam singh
on 2 Mar 2013
any one please having the solution.....please provide me the solution....
satnam singh
on 2 Mar 2013
why ..we are taking.. max([maxGLValueR, maxGLValueG, maxGLValueB]).. why 'max' is taken.....explain please..[0 maxGL 0 maxCount]... ...please explain...i am just a student ..so please provide the explanation...
Image Analyst
on 2 Mar 2013
It appears to be making plots, probably histograms, for each color. It normally will adjust the axes limits for each independently. This code appears to set up all three axes so that they all have the same limits so that it is easier to visually compare the histograms. It find the max gray level that any of the histograms will have and then sets up all three "x" axes to have that same limit rather than different limits. It also does the same thing for the "y" pixel count axes.
satnam singh
on 2 Mar 2013
Edited: Image Analyst
on 2 Mar 2013
redThresholdLow = graythresh(redBand);
redThresholdHigh = 255;
greenThresholdLow = 0;
greenThresholdHigh = graythresh(greenBand);
blueThresholdLow = 0;
blueThresholdHigh = graythresh(blueBand);
if true
redThresholdLow = uint8(redThresholdLow * 255);
greenThresholdHigh = uint8(greenThresholdHigh * 255);
blueThresholdHigh = uint8(blueThresholdHigh * 255);
end
Sir, why for red thresholdlow graythresh function is used but greenlow and bluelow are taken 0.after that why redlow and blue & green high are multiplied with 255 and unit 8 function is applied......
Image Analyst
on 2 Mar 2013
They want to find pixels for which the red signal is bright (between redThresholdLow and 255), and the green signal is dark (between 0 and greenThresholdHigh) and the blue signal is also dark (between 0 and blueThresholdHigh). They're probably trying to find the red spots on your Rubik's cube.
All the thresholds were determined using the graythresh() function which gives a number between 0 and 1 so you have to multiply the number by 255 for uint8 images, and 65535 for uint16 images.
satnam singh
on 5 Mar 2013
yellowObjectsMask = uint8(hueMask & saturationMask & valueMask); .. .. sir, why hsv image is used for yellow object detection ?? how taking all (hueMask & saturationMask & valueMask) is providing yellowobjectmask means how we are getting yellow objects only in the image...?? ... explain please...hoping for the reply soon....
Image Analyst
on 5 Mar 2013
We were sleeping. We do that sometimes over the night time. If you look at each mask individually you'll probably see how each does cover the yellow region, though may get more than just yellow, which is why 3 masks were combined to form the final mask.
satnam singh
on 5 Mar 2013
sorry sir for that...but i was little excited about completing my rubik's project....... where to use hsv color schemes besides of rgb...and how to mask of other colors such as orange....because while masking red in my program it was not Distinguishing between the red and orange..it was showing both the red and orange part as well......
Image Analyst
on 5 Mar 2013
Sorry - I was working at my day job. I do that when I'm not sleeping and helping people like you. Distinguishing orange and red would best be done in the HSV domain because you cannot carve out a box in RGB space to get orange without getting some red and yellow also. You just need to divide your hue image up into ranges that define each color. Good luck. I need to drive home and do something with my son so you may not hear from me for a while. But I have an HSV segmentation demo in my File Exchange so you can use that as an example.
satnam singh
on 6 Mar 2013
sir how to divide hue image up into ranges that define each color(or any color other than red,blue ,green).....hoping for reply soon......
satnam singh
on 6 Mar 2013
sir how to divide hue image up into ranges that define each color(or any color other than red,blue ,green).....please reply ...hoping for the reply soon....
satnam singh
on 6 Mar 2013
sir ,,how to know redthresholdlow,redhigh,greenlow,greenhigh,bluelow,bluehigh,yellolow,yellohigh,orangelow,orange high,,as this known values were used by you in your demo..for the onions,peppers,,etc....how u have get the information for these value in your demo....can i implement the same idea for my rubik,s face,,,,,including the previous question for HSV please reply soon...............
Image Analyst
on 6 Mar 2013
Sorry - unfortunately I was doing that annoying sleeping thing again. Here's how you can do it: http://www.mathworks.com/matlabcentral/fileexchange/28512-simple-color-detection-by-hue
satnam singh
on 6 Mar 2013
sir , i have gone through this demo earlier...but it is not discriminating amoung red ,orange and yellow on my rubik's face...what to do?????????????? please reply soon.......
Image Analyst
on 7 Mar 2013
Edited: Image Analyst
on 7 Mar 2013
satname, I don't know why you don't understand. You simply adapt the demo to use different hue values like I said. All you had to do was to change 2 lines to change the hue threshold between 0.06 and 0.12:
hueThresholdLow = 0.06;
hueThresholdHigh = 0.12;
Here's the whole huge demo again with those values in there. Select the peppers demo image, which has some orange and you'll see it picks out the orange peppers, and not the red or yellow peppers.
% Demo macro to very, very simple color detection in
% HSV (Hue, Saturation, Value) color space.
% Requires the Image Processing Toolbox. Developed under MATLAB R2010a.
%
function SimpleColorDetectionByHue()
clc; % Clear command window.
clear; % Delete all variables.
close all; % Close all figure windows except those created by imtool.
imtool close all; % Close all figure windows created by imtool.
workspace; % Make sure the workspace panel is showing.
% Change the current folder to the folder of this m-file.
% (The "cd" line of code below is from Brett Shoelson of The Mathworks.)
if(~isdeployed)
cd(fileparts(which(mfilename))); % From Brett
end
ver % Display user's toolboxes in their command window.
% Introduce the demo, and ask user if they want to continue or exit.
message = sprintf('This demo will illustrate very simple orange color detection\nin HSV color space.\nIt requires the Image Processing Toolbox.\nDo you wish to continue?');
reply = questdlg(message, 'Run Demo?', 'OK','Cancel', 'OK');
if strcmpi(reply, 'Cancel')
% User canceled so exit.
return;
end
try
% Check that user has the Image Processing Toolbox installed.
hasIPT = license('test', 'image_toolbox');
if ~hasIPT
% User does not have the toolbox installed.
message = sprintf('Sorry, but you do not seem to have the Image Processing Toolbox.\nDo you want to try to continue anyway?');
reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
if strcmpi(reply, 'No')
% User said No, so exit.
return;
end
end
% Continue with the demo. Do some initialization stuff.
close all;
fontSize = 16;
figure;
% Maximize the figure.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Change the current folder to the folder of this m-file.
% (The line of code below is from Brett Shoelson of The Mathworks.)
if(~isdeployed)
cd(fileparts(which(mfilename)));
end
% Ask user if they want to use a demo image or their own image.
message = sprintf('Do you want use a standard demo image,\nOr pick one of your own?');
reply2 = questdlg(message, 'Which Image?', 'Demo','My Own', 'Demo');
% Open an image.
if strcmpi(reply2, 'Demo')
% Read standard MATLAB demo image.
% fullImageFileName = 'peppers.png';
message = sprintf('Which demo image do you want to use?');
selectedImage = questdlg(message, 'Which Demo Image?', 'Onions', 'Peppers', 'Kids', 'Onions');
if strcmp(selectedImage, 'Onions')
fullImageFileName = 'onion.png';
elseif strcmp(selectedImage, 'Peppers')
fullImageFileName = 'peppers.png';
else
fullImageFileName = 'kids.tif';
end
else
% They want to pick their own.
% Change default directory to the one containing the standard demo images for the MATLAB Image Processing Toolbox.
originalFolder = pwd;
folder = 'C:\Program Files\MATLAB\R2010a\toolbox\images\imdemos';
if ~exist(folder, 'dir')
folder = pwd;
end
cd(folder);
% Browse for the image file.
[baseFileName, folder] = uigetfile('*.*', 'Specify an image file');
fullImageFileName = fullfile(folder, baseFileName);
% Set current folder back to the original one.
cd(originalFolder);
selectedImage = 'My own image'; % Need for the if threshold selection statement later.
end
% Check to see that the image exists. (Mainly to check on the demo images.)
if ~exist(fullImageFileName, 'file')
message = sprintf('This file does not exist:\n%s', fullImageFileName);
uiwait(msgbox(message));
return;
end
% Read in image into an array.
[rgbImage storedColorMap] = imread(fullImageFileName);
[rows columns numberOfColorBands] = size(rgbImage);
% If it's monochrome (indexed), convert it to color.
% Check to see if it's an 8-bit image needed later for scaling).
if strcmpi(class(rgbImage), 'uint8')
% Flag for 256 gray levels.
eightBit = true;
else
eightBit = false;
end
if numberOfColorBands == 1
if isempty(storedColorMap)
% Just a simple gray level image, not indexed with a stored color map.
% Create a 3D true color image where we copy the monochrome image into all 3 (R, G, & B) color planes.
rgbImage = cat(3, rgbImage, rgbImage, rgbImage);
else
% It's an indexed image.
rgbImage = ind2rgb(rgbImage, storedColorMap);
% ind2rgb() will convert it to double and normalize it to the range 0-1.
% Convert back to uint8 in the range 0-255, if needed.
if eightBit
rgbImage = uint8(255 * rgbImage);
end
end
end
% Display the original image.
subplot(3, 4, 1);
imshow(rgbImage);
drawnow; % Make it display immediately.
if numberOfColorBands > 1
title('Original Color Image', 'FontSize', fontSize);
else
caption = sprintf('Original Indexed Image\n(converted to true color with its stored colormap)');
title(caption, 'FontSize', fontSize);
end
% Convert RGB image to HSV
hsvImage = rgb2hsv(rgbImage);
% Extract out the H, S, and V images individually
hImage = hsvImage(:,:,1);
sImage = hsvImage(:,:,2);
vImage = hsvImage(:,:,3);
% [lowThreshold highThreshold lastThresholdedBand] = threshold(.06, .12, hImage);
% Display them.
subplot(3, 4, 2);
imshow(hImage);
title('Hue Image', 'FontSize', fontSize);
subplot(3, 4, 3);
imshow(sImage);
title('Saturation Image', 'FontSize', fontSize);
subplot(3, 4, 4);
imshow(vImage);
title('Value Image', 'FontSize', fontSize);
message = sprintf('These are the individual HSV color bands.\nNow we will compute the image histograms.');
reply = questdlg(message, 'Continue with Demo?', 'OK','Cancel', 'OK');
if strcmpi(reply, 'Cancel')
% User canceled so exit.
return;
end
% Compute and plot the histogram of the "hue" band.
hHuePlot = subplot(3, 4, 6);
[hueCounts, hueBinValues] = imhist(hImage);
maxHueBinValue = find(hueCounts > 0, 1, 'last');
maxCountHue = max(hueCounts);
bar(hueBinValues, hueCounts, 'r');
grid on;
xlabel('Hue Value');
ylabel('Pixel Count');
title('Histogram of Hue Image', 'FontSize', fontSize);
% Compute and plot the histogram of the "saturation" band.
hSaturationPlot = subplot(3, 4, 7);
[saturationCounts, saturationBinValues] = imhist(sImage);
maxSaturationBinValue = find(saturationCounts > 0, 1, 'last');
maxCountSaturation = max(saturationCounts);
bar(saturationBinValues, saturationCounts, 'g', 'BarWidth', 0.95);
grid on;
xlabel('Saturation Value');
ylabel('Pixel Count');
title('Histogram of Saturation Image', 'FontSize', fontSize);
% Compute and plot the histogram of the "value" band.
hValuePlot = subplot(3, 4, 8);
[valueCounts, valueBinValues] = imhist(vImage);
maxValueBinValue = find(valueCounts > 0, 1, 'last');
maxCountValue = max(valueCounts);
bar(valueBinValues, valueCounts, 'b');
grid on;
xlabel('Value Value');
ylabel('Pixel Count');
title('Histogram of Value Image', 'FontSize', fontSize);
% Set all axes to be the same width and height.
% This makes it easier to compare them.
maxCount = max([maxCountHue, maxCountSaturation, maxCountValue]);
axis([hHuePlot hSaturationPlot hValuePlot], [0 1 0 maxCount]);
% Plot all 3 histograms in one plot.
subplot(3, 4, 5);
plot(hueBinValues, hueCounts, 'r', 'LineWidth', 2);
grid on;
xlabel('Values');
ylabel('Pixel Count');
hold on;
plot(saturationBinValues, saturationCounts, 'g', 'LineWidth', 2);
plot(valueBinValues, valueCounts, 'b', 'LineWidth', 2);
title('Histogram of All Bands', 'FontSize', fontSize);
maxGrayLevel = max([maxHueBinValue, maxSaturationBinValue, maxValueBinValue]);
% Make x-axis to just the max gray level on the bright end.
xlim([0 1]);
% Now select thresholds for the 3 color bands.
message = sprintf('Now we will select some color threshold ranges\nand display them over the histograms.');
reply = questdlg(message, 'Continue with Demo?', 'OK','Cancel', 'OK');
if strcmpi(reply, 'Cancel')
% User canceled so exit.
return;
end
% Assign the low and high thresholds for each color band.
if strcmpi(reply2, 'My Own') || strcmpi(selectedImage, 'Kids') > 0
% Take a guess at the values that might work for the user's image.
hueThresholdLow = 0;
hueThresholdHigh = graythresh(hImage);
saturationThresholdLow = graythresh(sImage);
saturationThresholdHigh = 1.0;
valueThresholdLow = graythresh(vImage);
valueThresholdHigh = 1.0;
else
% Use values that I know work for the onions and peppers demo images.
hueThresholdLow = 0.06;
hueThresholdHigh = 0.12;
saturationThresholdLow = 0.4;
saturationThresholdHigh = 1;
valueThresholdLow = 0.8;
valueThresholdHigh = 1.0;
end
% Show the thresholds as vertical red bars on the histograms.
PlaceThresholdBars(6, hueThresholdLow, hueThresholdHigh);
PlaceThresholdBars(7, saturationThresholdLow, saturationThresholdHigh);
PlaceThresholdBars(8, valueThresholdLow, valueThresholdHigh);
message = sprintf('Next we will apply each color band threshold range to its respective color band.');
reply = questdlg(message, 'Continue with Demo?', 'OK','Cancel', 'OK');
if strcmpi(reply, 'Cancel')
% User canceled so exit.
return;
end
% Now apply each color band's particular thresholds to the color band
hueMask = (hImage >= hueThresholdLow) & (hImage <= hueThresholdHigh);
saturationMask = (sImage >= saturationThresholdLow) & (sImage <= saturationThresholdHigh);
valueMask = (vImage >= valueThresholdLow) & (vImage <= valueThresholdHigh);
% Display the thresholded binary images.
fontSize = 16;
subplot(3, 4, 10);
imshow(hueMask, []);
title('= Hue Mask', 'FontSize', fontSize);
subplot(3, 4, 11);
imshow(saturationMask, []);
title('& Saturation Mask', 'FontSize', fontSize);
subplot(3, 4, 12);
imshow(valueMask, []);
title('& Value Mask', 'FontSize', fontSize);
% Combine the masks to find where all 3 are "true."
% Then we will have the mask of only the red parts of the image.
orangeObjectsMask = uint8(hueMask & saturationMask & valueMask);
subplot(3, 4, 9);
imshow(orangeObjectsMask, []);
caption = sprintf('Mask of Only\nThe Orange Objects');
title(caption, 'FontSize', fontSize);
% Tell user that we're going to filter out small objects.
smallestAcceptableArea = 100; % Keep areas only if they're bigger than this.
message = sprintf('Note the small regions in the image in the lower left.\nNext we will eliminate regions smaller than %d pixels.', smallestAcceptableArea);
reply = questdlg(message, 'Continue with Demo?', 'OK','Cancel', 'OK');
if strcmpi(reply, 'Cancel')
% User canceled so exit.
return;
end
% Open up a new figure, since the existing one is full.
figure;
% Maximize the figure.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Get rid of small objects. Note: bwareaopen returns a logical.
orangeObjectsMask = uint8(bwareaopen(orangeObjectsMask, smallestAcceptableArea));
subplot(3, 3, 1);
imshow(orangeObjectsMask, []);
fontSize = 13;
caption = sprintf('bwareaopen() removed objects\nsmaller than %d pixels', smallestAcceptableArea);
title(caption, 'FontSize', fontSize);
% Smooth the border using a morphological closing operation, imclose().
structuringElement = strel('disk', 4);
orangeObjectsMask = imclose(orangeObjectsMask, structuringElement);
subplot(3, 3, 2);
imshow(orangeObjectsMask, []);
fontSize = 16;
title('Border smoothed', 'FontSize', fontSize);
% Fill in any holes in the regions, since they are most likely red also.
orangeObjectsMask = uint8(imfill(orangeObjectsMask, 'holes'));
subplot(3, 3, 3);
imshow(orangeObjectsMask, []);
title('Regions Filled', 'FontSize', fontSize);
message = sprintf('This is the filled, size-filtered mask.\nNext we will apply this mask to the original RGB image.');
reply = questdlg(message, 'Continue with Demo?', 'OK','Cancel', 'OK');
if strcmpi(reply, 'Cancel')
% User canceled so exit.
return;
end
% You can only multiply integers if they are of the same type.
% (orangeObjectsMask is a logical array.)
% We need to convert the type of orangeObjectsMask to the same data type as hImage.
orangeObjectsMask = cast(orangeObjectsMask, class(rgbImage));
% Use the orange object mask to mask out the orange-only portions of the rgb image.
maskedImageR = orangeObjectsMask .* rgbImage(:,:,1);
maskedImageG = orangeObjectsMask .* rgbImage(:,:,2);
maskedImageB = orangeObjectsMask .* rgbImage(:,:,3);
% Show the masked off red image.
subplot(3, 3, 4);
imshow(maskedImageR);
title('Masked Red Image', 'FontSize', fontSize);
% Show the masked off saturation image.
subplot(3, 3, 5);
imshow(maskedImageG);
title('Masked Green Image', 'FontSize', fontSize);
% Show the masked off value image.
subplot(3, 3, 6);
imshow(maskedImageB);
title('Masked Blue Image', 'FontSize', fontSize);
% Concatenate the masked color bands to form the rgb image.
maskedRGBImage = cat(3, maskedImageR, maskedImageG, maskedImageB);
% Show the masked off, original image.
subplot(3, 3, 8);
imshow(maskedRGBImage);
fontSize = 13;
caption = sprintf('Masked Original Image\nShowing Only the orange Objects');
title(caption, 'FontSize', fontSize);
% Show the original image next to it.
subplot(3, 3, 7);
imshow(rgbImage);
title('The Original Image (Again)', 'FontSize', fontSize);
% Measure the mean HSV and area of all the detected blobs.
[meanHSV, areas, numberOfBlobs] = MeasureBlobs(orangeObjectsMask, hImage, sImage, vImage);
if numberOfBlobs > 0
fprintf(1, '\n----------------------------------------------\n');
fprintf(1, 'Blob #, Area in Pixels, Mean H, Mean S, Mean V\n');
fprintf(1, '----------------------------------------------\n');
for blobNumber = 1 : numberOfBlobs
fprintf(1, '#%5d, %14d, %6.2f, %6.2f, %6.2f\n', blobNumber, areas(blobNumber), ...
meanHSV(blobNumber, 1), meanHSV(blobNumber, 2), meanHSV(blobNumber, 3));
end
else
% Alert user that no orange blobs were found.
message = sprintf('No orange blobs were found in the image:\n%s', fullImageFileName);
fprintf(1, '\n%s\n', message);
uiwait(msgbox(message));
end
subplot(3, 3, 9);
ShowCredits();
message = sprintf('Done!\n\nThe demo has finished.\n\nLook the MATLAB command window for\nthe area and color measurements of the %d regions.', numberOfBlobs);
msgbox(message);
catch ME
errorMessage = sprintf('Error running this m-file:\n%s\n\nThe error message is:\n%s', ...
mfilename('fullpath'), ME.message);
errordlg(errorMessage);
end
return; % from SimpleColorDetection()
% ---------- End of main function ---------------------------------
%----------------------------------------------------------------------------
function [meanHSV, areas, numberOfBlobs] = MeasureBlobs(maskImage, hImage, sImage, vImage)
[labeledImage numberOfBlobs] = bwlabel(maskImage, 8); % Label each blob so we can make measurements of it
if numberOfBlobs == 0
% Didn't detect any orange blobs in this image.
meanHSV = [0 0 0];
areas = 0;
return;
end
% Get all the blob properties. Can only pass in originalImage in version R2008a and later.
blobMeasurementsHue = regionprops(labeledImage, hImage, 'area', 'MeanIntensity');
blobMeasurementsSat = regionprops(labeledImage, sImage, 'area', 'MeanIntensity');
blobMeasurementsValue = regionprops(labeledImage, vImage, 'area', 'MeanIntensity');
meanHSV = zeros(numberOfBlobs, 3); % One row for each blob. One column for each color.
meanHSV(:,1) = [blobMeasurementsHue.MeanIntensity]';
meanHSV(:,2) = [blobMeasurementsSat.MeanIntensity]';
meanHSV(:,3) = [blobMeasurementsValue.MeanIntensity]';
% Now assign the areas.
areas = zeros(numberOfBlobs, 3); % One row for each blob. One column for each color.
areas(:,1) = [blobMeasurementsHue.Area]';
areas(:,2) = [blobMeasurementsSat.Area]';
areas(:,3) = [blobMeasurementsValue.Area]';
return; % from MeasureBlobs()
%----------------------------------------------------------------------------
% Function to show the low and high threshold bars on the histogram plots.
function PlaceThresholdBars(plotNumber, lowThresh, highThresh)
% Show the thresholds as vertical red bars on the histograms.
subplot(3, 4, plotNumber);
hold on;
maxYValue = ylim;
maxXValue = xlim;
hStemLines = stem([lowThresh highThresh], [maxYValue(2) maxYValue(2)], 'r');
children = get(hStemLines, 'children');
set(children(2),'visible', 'off');
% Place a text label on the bar chart showing the threshold.
fontSizeThresh = 14;
annotationTextL = sprintf('%d', lowThresh);
annotationTextH = sprintf('%d', highThresh);
% For text(), the x and y need to be of the data class "double" so let's cast both to double.
text(double(lowThresh + 5), double(0.85 * maxYValue(2)), annotationTextL, 'FontSize', fontSizeThresh, 'Color', [0 .5 0], 'FontWeight', 'Bold');
text(double(highThresh + 5), double(0.85 * maxYValue(2)), annotationTextH, 'FontSize', fontSizeThresh, 'Color', [0 .5 0], 'FontWeight', 'Bold');
% Show the range as arrows.
% Can't get it to work, with either gca or gcf.
% annotation(gca, 'arrow', [lowThresh/maxXValue(2) highThresh/maxXValue(2)],[0.7 0.7]);
return; % from PlaceThresholdBars()
%----------------------------------------------------------------------------
% Display the MATLAB logo.
function ShowCredits()
% xpklein;
% surf(peaks(30));
logoFig = subplot(3,3,9);
caption = sprintf('A MATLAB Demo');
text(0.5,1.15, caption, 'Color','r', 'FontSize', 18, 'FontWeight','b', 'HorizontalAlignment', 'Center') ;
positionOfLowerRightPlot = get(logoFig, 'position');
L = 40*membrane(1,25);
logoax = axes('CameraPosition', [-193.4013 -265.1546 220.4819],...
'CameraTarget',[26 26 10], ...
'CameraUpVector',[0 0 1], ...
'CameraViewAngle',9.5, ...
'DataAspectRatio', [1 1 .9],...
'Position', positionOfLowerRightPlot, ...
'Visible','off', ...
'XLim',[1 51], ...
'YLim',[1 51], ...
'ZLim',[-13 40], ...
'parent',gcf);
s = surface(L, ...
'EdgeColor','none', ...
'FaceColor',[0.9 0.2 0.2], ...
'FaceLighting','phong', ...
'AmbientStrength',0.3, ...
'DiffuseStrength',0.6, ...
'Clipping','off',...
'BackFaceLighting','lit', ...
'SpecularStrength',1.1, ...
'SpecularColorReflectance',1, ...
'SpecularExponent',7, ...
'Tag','TheMathWorksLogo', ...
'parent',logoax);
l1 = light('Position',[40 100 20], ...
'Style','local', ...
'Color',[0 0.8 0.8], ...
'parent',logoax);
l2 = light('Position',[.5 -1 .4], ...
'Color',[0.8 0.8 0], ...
'parent',logoax);
return; % from ShowCredits()
satnam singh
on 8 Mar 2013
sir, how to suppress or eradicate the background image from the real time image of any object..such as in case of my rubik,s face.......sir, this time , i am trying a total different approach.......i just want to get the roi which is in case my rubik,s face..change it into gray level..divide it into nine blocks as nine blocks on rubik's face....take the mean...i think for the same color blocks..the mean would be nearly the same. ..and in this way provide particular integer to the different colors(so firstly provide me the approach to suppress background image and after that the other things described) ...........................is this approachpractical.....how to proceed towards this.............please reply soon..............
Image Analyst
on 8 Mar 2013
Snap an image and call it backgroundImage. Then compare to most recent snap to see which pixels in the most recent snap match the background:
tolerance = 5; % gray levels.
backgroundMask = abs(double(backgroundImage) - double(lastSnap)) < tolerance;
Then erase pixels in the most recent snap that are close to the background image.
% Erase background
uniformGrayLevel = 0; % or whatever color you want the background to be.
lastSnap(backgroundMask) = uniformGrayLevel;
satnam singh
on 13 Mar 2013
sir,suppose a human being sees a particular color..then he observes and says that this particular color is approximately equal to some color(say orange)...how he is able to do this approximation??? can we apply such algorithm for any given color and say that given color is equal to the some color which is in knowledge........
satnam singh
on 14 Mar 2013
sir what if i create the white background ...and then our ROI will be just rubik's face...then how to identify the four corners of the face and depending on the four corners how to create the quadilateral bounding the rubik,s face...then dividing the qudilateral in nine equal blocks for the processing...how to do that...please suggest some program as well as the simulink model......
More Answers (0)
See Also
Categories
Find more on Rubik's Cube in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
