I created a matlab gui to determine the length and width of a foot, the area of an existing foot, and use it to determine the size of the foot as well. here is the code I used

34 views (last 30 days)
I created a matlab gui to determine the length and width of a foot, the area of an existing foot, and use it to determine the size of the foot as well. here is the code I used. but why do the results tend to be invalid, is there a solution?
a=getappdata(0,'a');
a_gray=rgb2gray(a);
axes(handles.axes2);
imshow(a_gray);
% Menetapkan ambang batas (contoh: ambang batas = 150, sesuaikan sesuai kebutuhan)
threshold = 115;
% Membuat mask untuk piksel cerah
brightPixelsMask = a_gray > threshold;
% Menampilkan gambar grayscale yang hanya menyoroti piksel cerah di axes 2
imshow(brightPixelsMask, 'Parent', handles.axes2);
% Menghitung panjang dan lebar dari area cerah
stats = regionprops(brightPixelsMask, 'MajorAxisLength', 'MinorAxisLength');
if ~isempty(stats)
majorAxisLength = stats.MajorAxisLength;
minorAxisLength = stats.MinorAxisLength;
% Menampilkan hasil di static text
resultString = sprintf('Panjang: %.2f pixel, Lebar: %.2f pixel', majorAxisLength, minorAxisLength);
set(handles.text3, 'String', resultString);
% Meminta pengguna untuk memasukkan nilai resolusi
prompt = 'Masukkan nilai resolusi (PPI):';
dlgTitle = 'Input Resolusi';
numLines = 1;
defaultResolusi = '300'; % Nilai default
answer = inputdlg(prompt, dlgTitle, numLines, {defaultResolusi});
if ~isempty(answer)
% Mengambil nilai resolusi dari masukan pengguna
resolusiScanner = str2double(answer{1});
% Menghitung panjang dan lebar dalam milimeter
panjang_mm = (majorAxisLength / resolusiScanner) * 2540 * 10;
lebar_mm = (minorAxisLength / resolusiScanner) * 2540 * 10;
% Menampilkan hasil akhir di static text
resultStringFinal = sprintf('Panjang: %.2f mm, Lebar: %.2f mm', panjang_mm, lebar_mm);
set(handles.text3, 'String', resultStringFinal);
else
% Jika pengguna membatalkan pemilihan resolusi
set(handles.text3, 'String', 'Pemilihan resolusi dibatalkan.');
end
else
% Jika tidak ada area cerah, tampilkan pesan kosong
set(handles.text3, 'String', 'Tidak ada area cerah.');
end
  5 Comments
rizqi basith
rizqi basith on 1 Apr 2024 at 16:01
@DGM because I did the foot scan, I really have the full specifications of the image, sorry i can not understand for for the questions about "how i trying to present it" what it mean?
Walter Roberson
Walter Roberson on 1 Apr 2024 at 19:14
No, the results of the foot scan in jpeg format cannot simultaneously store heat and pressure. JPEG can store only one value per location, so you would need two jpeg to store both heat and pressure.

Sign in to comment.

Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!