Computer Vision News - September 2021
2 Summary Co puter Vision Tool 8 methods (Access = private) function updateimage (app,imagefile) % Find an instance of an image for each category labelIm = find(app.testSet.Labels == imagefile); % generate one random index randIdc = randperm(length(labelIm), 1 ); % initialize R to be the four numbers of A R = labelIm(randIdc); try app.testImage = readimage(app.testSet,R); catch ME % If problem reading image, display error message uialert(app.UIFigure, ME.message, 'Image Error'); return ; end % Create histograms based on number of color channels switch size(app.testImage, 3 ) case 1 % Display the grayscale image imagesc(app.ImageAxes,app.testImage); % Plot all histograms with the same data for grayscale histr = histogram(app.RedAxes, app.testImage, 'FaceColor',[ 1 0 0 ],'EdgeColor', 'none'); histg = histogram(app.GreenAxes, app.testImage, 'FaceColor',[ 0 1 0 ],'EdgeColor', 'none'); histb = histogram(app.BlueAxes, app.testImage, 'FaceColor',[ 0 0 1 ],'EdgeColor', 'none'); case 3 % Display the truecolor image imagesc(app.ImageAxes,app.testImage); % Plot the histograms histr = histogram(app.RedAxes, app.testImage(:,:, 1 ), 'FaceColor', [ 1 0 0 ], 'EdgeColor', 'none'); histg = histogram(app.GreenAxes, app.testImage(:,:, 2 ), 'FaceColor', [ 0 1 0 ], 'EdgeColor', 'none'); histb = histogram(app.BlueAxes, app.testImage(:,:, 3 ), 'FaceColor', [ 0 0 1 ], 'EdgeColor', 'none'); otherwise % Error when image is not grayscale or truecolor uialert(app.UIFigure, 'Image must be grayscale or truecolor.', 'Image Error'); return ; end % Get largest bin count maxr = max(histr.BinCounts); maxg = max(histg.BinCounts); maxb = max(histb.BinCounts);
Made with FlippingBook
RkJQdWJsaXNoZXIy NTc3NzU=