이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
I have an error in the code below in writing an image please help
imwrite((gsq, []),strtemp)
Expression or statement is incorrect--possibly unbalanced (, {, or [
I have posted question regarding this and have got answer,but still getting same error
채택된 답변
Image Analyst
2011년 12월 10일
0 개 추천
Why do you have the () and [] in there? You're supposed to be passing a numerical array and a string that is the filename. Did you look up the help for imwrite?
댓글 수: 8
Pat
2011년 12월 10일
if i am not using [ ] ,the image is black in colour,if i use i get the image,i could not find any in imwrite
Walter Roberson
2011년 12월 10일
Sounds like you are trying to use [] to do the equivalent of imagesc(), scaling the image. imwrite() does not support any such option. You have to scale the data before you write it.
Jan
2011년 12월 10일
"(gsq, [])" is simply no valid expression in Matlab. What do you expect it to do?
Pat
2011년 12월 12일
this is my code
clc
clear all
pathname ='D:\dataset1\' ;
dirlist = dir( [pathname '*.jpg'] );
pickind='jpg';
for m = 1:length(dirlist)
im = double((imread([pathname, dirlist(m).name])))/256;
im=rgb2gray(im);
[xg, yg] = gradients_xy(im, 5, false, [1 size(im,1) 1 size(im,2)]);
gsq = xg.^2 + yg.^2;
%imshow(gsq, []);
% figure, imshow(gsq, []),%title('org image')
strtemp=strcat('D:\shape\',int2str(m),'.',pickind);
imwrite((gsq ,[]),strtemp)
end
i get erro if i use "(gsq, [])" ,only if i use this code,i get the image,if i use gsq i get only white coloured image
i want to write this image to a folder please help
Walter Roberson
2011년 12월 12일
Already answered when you asked it in http://www.mathworks.com/matlabcentral/answers/23562-how-to-introduce-delay
Key phrase in my response:
"Warning: there is no way to tell imwrite() that you want the image to be automatically scaled the way you would by using [] as an argument to imshow()."
I have posted scaling code several times, and there are file exchange contributions to do the scaling, such as http://www.mathworks.com/matlabcentral/fileexchange/7943-freezecolors-unfreezecolors
Pat
2011년 12월 12일
walter can u tell why the image is black in colouw when using imshow(gsq),and i get image wen i use imwrite(gsq ,[])
I have resized the image but i get same black image ,please ezplain
Image Analyst
2011년 12월 12일
You use [] when displaying a floating point image in imshow. That will scale it for display. Otherwise it expects the image to be in the range 0-1 and if you have values outside that it will clip them and only show you the pixels that ARE within the range 0-1, which may be very very few, if any, pixels. So, you basically see all black if you don't use [] with imshow and you're displaying a floating point image. Now, with your imwrite, it normally wants an integer image. Exactly what do you think you're doing when you do (gsq, [])? Why are you doing that instead of simply gsq? Why??? We've told you a few times now: use [] with imshow, NOT with imwrite. Please believe us. And why didn't you cast gsq into an integer, scaling it if necessary, like Walter suggested? Please please do that. At least give it a try. If you really need to save it as a floating point image for later use in MATLAB, then I recommend saving the variable in a .mat file using save() instead of using imwrite().
Pat
2011년 12월 12일
Thanks a lot
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Arithmetic에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)
