File Exchange

image thumbnail

red,Green,Blue from RGB image

version 1.0.0.0 (880 Bytes) by kiran kumar
Hi everyone this is just a basic idea for extracting red,Green,Blue colrs from an RGB image

1 Download

Updated 07 Feb 2015

View License

Hi everyone .This is just a sample program used for extracting Red,Gree,Blue from an RGB image.

Comments and Ratings (1)

Jan

This is a script, which clears the base workspace brutally by a "clear all" and closes all open windows, although there is no benefit to do so. This method removed all breakpoints also, which impedes a debugging of this and all other code. And anything, which impedes debugging is the programmer's enemy.

There is no need to convert the string "file" by a char() to a string. Shadowing the important command "path" by a local variable might lead to severe side-effects. Later on the path is not considered anymore. Better:
Img = imread(fullfile(FolderName, FileName));

The size() command replies the dimensions of the array as a vector. Then the command "if S>2" does not do, what you expect, because it checks, if all elements of S are larger than 2. I guess you mean "if ndims(file) > 2": Check if the imported image has more than 2 dimensions, such that it is an RGB image.

Re-using the name "file" for the file name and the contents of the image is confusing.

Checking if the user pressed "Cancel" in uigetfile works, but it is not clean: if file==0 compares all characters of the filename. Using ~ischar(file) or "if isequal(file, 0)" would be better - although it is not a hard error here.

In consequence I think this code is neither useful for productive code nor for educational purposes. I strongly recommend to clean it substantially.

MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux