Paint by numbers with Matlab. Imcontour function
이전 댓글 표시
Hi! I am working for my diploma project and I encounter some difficulties. I am trying to make a paint by number program where you put an image and the program shows the contour of the colors and the colorbar. Also I want to label every area of the contour with the number of the color that is in that area. I have managed to do this but it's not the result I am expecting. As you can see in the image below, the labels of the colors are on the lines and not on the contoured area and the colorbar is a gradient and not separate colors as they are in the colorbar of an indexed image. How can I make more accurate contour regions and to label them in the middle of the region not on the line? How can I make the colorbar to appear as separate colors and not as a gradient?

[IND,map] = rgb2ind(I,10);
imagesc(app.UIAxes, I);
s=colorbar(app.UIAxes);
colormap(app.UIAxes,map);
imshow(I,'Parent',app.UIAxes);
I2=ind2gray(IND,map);
colormap(app.UIAxes, map);
axis image;
%imshow(I2,'Parent',app.UIAxes);
[C,h]=imcontour(I2,'-k');
clabel(C,h)
colorbar;
댓글 수: 1
DGM
2021년 7월 2일
For the colorbar, make sure to assert
colormap(axeshandle,map)
after you run imcontour().
That said, the difficulty of figuring out how to move the labels leaves me thinking that using contour() probably isn't the simplest way to do this. I might think about that one for a bit.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Region and Image Properties에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


