Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

want to reag .pgm images in matlab but get an error index exceeds matrix dimension

조회 수: 2 (최근 30일)
divya
divya 2013년 6월 2일
마감: MATLAB Answer Bot 2021년 8월 20일
imwrite(imread('divya.pgm'),'C:\Users\div\Desktop\myfirstimage.jpg')
i am using this to read a pgm file..but i get an error index exceeds matrix dimention.please help

답변 (1개)

Image Analyst
Image Analyst 2013년 6월 2일
Let's break it down so we can see where the error is coming from:
originalImage = imread('divya.pgm')
imshow(originalImage);
imwrite(originalImage,'C:\Users\div\Desktop\myfirstimage.jpg')
Now what happens? Paste all the red error message text - don't paraphrase or cut anything.
  댓글 수: 2
divya
divya 2013년 6월 2일
Index exceeds matrix dimensions.
Error in createLightSource (line 26)
G = round(sin(phi) * sum(sum(image(up:down,left:right,2))));
Error in cut (line 139)
createLightSource(cImage, left1, right1, up1, down1, r, n, m);
Error in cut (line 130)
cImage = cut(cImage, gsImage, left1, right1, up1, down1, n_now+1, n, r, m);
Error in cut (line 130)
cImage = cut(cImage, gsImage, left1, right1, up1, down1, n_now+1, n, r, m);
Error in varianceCut (line 50)
output = cut(input, greyscaleImage, left, right, up, down, 1, n, r, m); Error in program (line 74)
cutImage = varianceCut( rgb, n, r, m);
Image Analyst
Image Analyst 2013년 6월 2일
Wow - that's really bizarre. That doesn't look anything like your original code, or my code. Are createLightSource(), cut(), and varianceCut() your functions? Or something from some toolbox?
One thing that looks weird is:
G = round(sin(phi) * sum(sum(image(up:down,left:right,2))));
image() is a built in function that takes an image variable and displays it. It's probably getting confused when you pass it two 2-element arrays and a scalar (2). You don't have an image anywhere in your code that you gave the name "image" to, do you? That would be bad. If you do, call your variable something else, like grayImage, originalImage, croppedImage, rgbImage, or something, anything, other than "image".

이 질문은 마감되었습니다.

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by