Azzera filtri
Azzera filtri

while processing a code for Image enhnacement..i am getting the following error could you please explain..?

1 visualizzazione (ultimi 30 giorni)
*Error using rgb2gray>parse_inputs (line 88) RGB must be a m x n x 3 array.
Error in rgb2gray (line 35) X = parse_inputs(varargin{:});*
  1 Commento
Rajat
Rajat il 10 Apr 2013
I was intially trying to input some urban area image with .img format but Matlab is not supporting..??..how can i input coloured input image of urban area and extract building

Accedi per commentare.

Risposte (2)

Iman Ansari
Iman Ansari il 10 Apr 2013
Modificato: Iman Ansari il 10 Apr 2013
The error says why. Your input is not RGB. Try:
size('your input')
  2 Commenti
Rajat
Rajat il 10 Apr 2013
thanx for reply..but i want to actually input a urban area satlelite image..but wen i input.img image...it doesnot support
Rajat
Rajat il 10 Apr 2013
below is code for image segmentation could you please help in doin necessary changes, so that i can extract building from satellite image
im1=imread('D:\12.jp2'); %im1=rgb2gray(im); im1=medfilt2(im1,[3 3]); %Median filtering the image to remove noise% BW = edge(im1,'sobel'); %finding edges [imx,imy]=size(BW); msk=[0 0 0 0 0; 0 1 1 1 0; 0 1 1 1 0; 0 1 1 1 0; 0 0 0 0 0;]; B=conv2(double(BW),double(msk)); %Smoothing image to reduce the number of connected components L = bwlabel(B,8);% Calculating connected components mx=max(max(L)) % There will be mx connected components.Here U can give a value between 1 and mx for L or in a loop you can extract all connected components % If you are using the attached car image, by giving 17,18,19,22,27,28 to L you can extract the number plate completely. [r,c] = find(L==17); rc = [r c]; [sx sy]=size(rc); n1=zeros(imx,imy); for i=1:sx x1=rc(i,1); y1=rc(i,2); n1(x1,y1)=255; end % Storing the extracted image in an array %figure,imshow(im); figure,imshow(im1); figure,imshow(B); figure,imshow(n1,[]);

Accedi per commentare.


Image Analyst
Image Analyst il 10 Apr 2013
After you call this line
im1 = imread('D:\12.jp2');
put these lines
[rows, columns, numberOfColorChannels] = size(im1) % No semicolon
if numberOfColorChannels > 1
% Do this only if you want to convert to gray level.
im1 = rgb2gray(im1);
% Optionally, can take the green channel instead of the above line
% im1 = im1(:, :, 2);
end
What does this print out in the command window?
  6 Commenti
Joe Torr
Joe Torr il 8 Feb 2015
I tried your step and it gave me the same error. I wonder if it's the fact that my image is .tiff have something to do with it. I'm just trying a basic step of getting only black and white colors. I started to try gray but that did'nt work as well.
Image Analyst
Image Analyst il 8 Feb 2015
Joe, I don't know what you did. Post your own question separately, and attach your code and image and we'll answer it there.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by