이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Error with function duplicate name where there is only one function.
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello
Matlab tries to call a function with the name "SegmentBone" as you can see from the example but I get the error of duplicate name and that Matlab cannot define it. There is only one SegmentBone.m in the folder. Why duplicate name?
Error: File: SegmentBone.m Line: 7 Column: 18
Function with duplicate name "SegmentBone" cannot be defined.
Error in Test1 (line 38)
imSeg = SegmentBone(im, 10e6, 0.031);
댓글 수: 9
Adam Danz
2019년 6월 18일
Make sure your main function name matches the m file name and that you don't have two different functions with the same name within the file. This demo below reproduces your error (saved in a file name SegmentBone.m).
function y= SegmentBone(x)
q = jff(4);
y = x * q;
function q = SegmentBone(x)
q = x+1;
y = SegmentBone(1);
Error: File: SegmentBone.m Line: 7 Column: 14
Function with duplicate name "SegmentBone" cannot be defined.
Stelios Fanourakis
2019년 6월 18일
I use that code. There is no SegmentBone.m in the same script anywhere else or in the working folder.
% Apply the bone segmentation to test image and show the results
clc
close all
clear all
path = imread('2A.bmp');
imROIminX = 159;
imROImaxX = 536;
imROIminY = 33;
imROImaxY = 410;
% path = 'Z:\Data\Cadaver_Experiment_2\Data\MaleCadaver\1\center\im';
% imROIminX = 159;
% imROImaxX = 536;
% imROIminY = 33;
% imROImaxY = 410;
i = 69; %81;
lp = sprintf('%s%04d.bmp', path, i);
im = imread('2A.bmp');
%%
%
% for x = 1:10
%
% for x = 1:10
% disp(x)
% end
%
% disp(x)
% end
%
im = im(imROIminY:imROImaxY, imROIminX:imROImaxX);
im = im2double(im);
[imH, imW] = size(im);
% im = flipdim(im,2);
figure, imshow(im);
tic
imSeg = SegmentBone(im, 10e6, 0.031);
toc
% figure, imshow(imSeg)
im4 = imresize(im,size(imSeg));
% subplot(1,2,1), imshow(im4)
% subplot(1,2,2), imshow(imSeg)
[BoneIdx] = find(imSeg>0);
imOverlapped = im4;
imOverlapped(BoneIdx) = 1;
figure, imshow(imOverlapped)
% imwrite(im4,'results\5_original.bmp','bmp');
% imwrite(imOverlapped,'results\T9SegIM.bmp','bmp');
Stelios Fanourakis
2019년 6월 18일
편집: Stelios Fanourakis
2019년 6월 18일
1) Yes it's the correct function
This is the SegmentBone.m function. It starts at line 7 where all the previous lines are comments in green
function imSeg = SegmentBone(USimage, USfreq, USdepth)
[imH, imW] = size(USimage);
% calculate the segmentation parameters from US image parameters
boneTh = 1/8; % used for masking
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Downsampling
DownSampleFactor = 4;
% filter
Gsigma = 6;
hsize = floor(Gsigma*3)*2+1;
h = fspecial('gaussian', hsize, Gsigma);
imBlured = imfilter(USimage, h, 'replicate', 'same');
imBlured = imBlured(1:DownSampleFactor:imH,1:DownSampleFactor:imW);
imBlured = AdjustContrast(imBlured);
figure, imshow(imBlured)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
h = [0 -1 0; -1 4 -1; 0 -1 0];
imBLOG = imfilter(imBlured, h, 'replicate', 'same');
imBLOG = (imBLOG>0).*imBLOG;
imBLOG = imBLOG/max(imBLOG(:));
figure, imshow(imBLOG)
% To make the algorithm faster, keep track of the points that are probable
% to be the bone surface
% First: Apply the threshold to the image (this is a loose threshold)
imMask = (imBlured >= boneTh);
[imH, imW] = size(imMask);
BorderRigeon = round((0.002/USdepth)*imH);
imMask(1:BorderRigeon,:) = 0;
% calculate the weight for underneath shadowness
Wshw = CalcBoneShadow(imMask, imBlured);
figure, imshow(Wshw);
% calculate the intensity weight
Wint = imMask .* (imBlured+imBLOG);
Wint = AdjustContrast(Wint);
figure, imshow(Wint);
% calculate the total Boniness, (Multipication prefered over addition)
Bness = Wshw.*Wint;
Bness = Bness/max(Bness(:)); % normalize
figure, imshow(Bness);
% imwrite(Bness, 'results\cadaver_2_50_Bness.bmp', 'bmp');
% Find bone surface using Dynamic Programming
% Smoothness will be applied through DP
% Presence of bone will be also determined using DP
% imSeg = FindBoneDP(Bness);
F0 = 50.0; F1 = 100.0; Bth = 0.55; % bone threshold between 0 and 1
JumpConst = 1.5;
% imSeg = FindBoneDP(Bness,F0,F1,Bth,JumpConst);
imSeg = SegmentBoneDP(Bness,F0,F1,Bth,JumpConst);
end
Adam Danz
2019년 6월 18일
편집: Adam Danz
2019년 6월 18일
My first "quick thing" doesn't address whether you're using the correct function. It confirms that there are no other files with the same name. Did you run that line? What does it output?
which SegmentBone -all
Also, what version of matlab are you using? If there are any non-comments prior to the first line of code where the function is declared, that would produce the error you're getting (in r2016a or prior).
Stelios Fanourakis
2019년 6월 18일
No, there is only one segmentBone.m function using the which command
I use R2018b
Adam Danz
2019년 6월 18일
If you attach SegmentBone.m, Test1.m, 2A.bmp, and any other inputs needed to recreate the problem, I can look into it further.
Stelios Fanourakis
2019년 6월 18일
I use the line
mex SegmentBone.cpp
This should do the compiling from cpp to Mex. However, I get the error
mex SegmentBoneDP.cpp
Building with 'Xcode Clang++'.
Error using mex
/Users/steliosphanourakes/Desktop/Matlab/DesMoines/karadokei -
Copy/FANOURAKIS_STELIOS12/20190516144930/SegmentBoneDP.cpp:17:17: error: assigning to 'const int *' from
incompatible type 'const mwSize *' (aka 'const unsigned long *')
DimsBness = mxGetDimensions(prhs[0]);
^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018b.app/extern/include/matrix.h:243:25: note: expanded from macro 'mxGetDimensions'
#define mxGetDimensions mxGetDimensions_730
^
/Users/steliosphanourakes/Desktop/Matlab/DesMoines/karadokei -
Copy/FANOURAKIS_STELIOS12/20190516144930/SegmentBoneDP.cpp:30:15: error: no matching function for call to
'mxCreateNumericArray_730'
plhs[0] = mxCreateNumericArray(2,DimsBness,mxDOUBLE_CLASS,mxREAL);
^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018b.app/extern/include/matrix.h:275:30: note: expanded from macro 'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018b.app/extern/include/matrix.h:1247:1: note: candidate function not viable: no known
conversion from 'const int *' to 'const mwSize *' (aka 'const unsigned long *') for 2nd argument
mxCreateNumericArray(mwSize ndim, const mwSize *dims, mxClassID classid, mxComplexity flag);
^
/Applications/MATLAB_R2018b.app/extern/include/matrix.h:275:30: note: expanded from macro 'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^
2 errors generated.
Anyone who can responsibly help me?
Thanks
Walter Roberson
2019년 6월 18일
You duplicated that into another question. The volunteers are not fond of answering the same query in three different Questions.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
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)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)