i am getting the error while reading the images (2024)

2 views (last 30 days)

Show older comments

Pavan Kumar M.P on 13 Jan 2018

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/376990-i-am-getting-the-error-while-reading-the-images

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/376990-i-am-getting-the-error-while-reading-the-images

Commented: Image Analyst on 13 Jan 2018

Accepted Answer: Image Analyst

Open in MATLAB Online

ipDir = '../Dataset/photos'; isDir = '../Dataset/sketches';

files_p = dir([ipDir '*.jpg']); files_s = dir([isDir '*.jpg']);

tmp1=imread([ipDir files_p(1).name]); Index exceeds matrix dimensions.

Error in createTrainingData_color (line 13) tmp1=imread([ipDir files_p(1).name]);

I am getting the above error. Please help me.

I am getting the error while reading the images.

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

Accepted Answer

Image Analyst on 13 Jan 2018

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/376990-i-am-getting-the-error-while-reading-the-images#answer_299988

Open in MATLAB Online

Evidently the length is zero and so when you try to access index 1, it says "Index exceeds matrix dimensions." Try this more robust way:

if length(files_p) > 0

fullFileName = fullfile(ipDir, files_p(1).name);

tmp1=imread(fullFileName);

end

2 Comments

Show NoneHide None

Pavan Kumar M.P on 13 Jan 2018

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/376990-i-am-getting-the-error-while-reading-the-images#comment_524365

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/376990-i-am-getting-the-error-while-reading-the-images#comment_524365

Open in MATLAB Online

files_p = dir([ipDir '*.jpg']); files_s = dir([isDir '*.jpg']);

%Find the nubmer files and the size of images

tmp1=imread([ipDir , files_p(1).name]); nFile = numel(files_p); [nRow, nCol, nCh] = size(tmp1);

%initialize matrix for data pImg_luv = zeros(nRow,nCol,nCh, nFile); pImg_rgb = zeros(nRow,nCol,nCh, nFile);

pImg = zeros(nRow,nCol,nFile); sImg = zeros(nRow,nCol,nFile); intImg = zeros(nRow,nCol,nFile); nRowPatch = nRow-pSize(1); nColPatch = nCol- pSize(2); squareSum = zeros(nRowPatch, nColPatch, nFile);

for i=1:nFile tmp1=imread([ipDir files_p(i).name]); pImg(:,:,i)=single(rgb2gray(tmp1));

pImg_rgb(:,:,:,i)= tmp1;

pImg_luv(:,:,:,i)= rgb2luv(tmp1);

intImg(:,:,i) = integralimage(pImg(:,:,i).^2);

%IRs

for m=1:nRowPatch

for n=1:nColPatch

squareSum(m,n,i)=intImg(m,n,i)+intImg(m+pSize(1)-1,n+pSize(2)-1,i)-intImg(m,n+pSize(2)-1,i)-intImg(m+pSize(1)-1,n,i);

end

end

tmp2=imread([isDir files_s(i).name]);

sImg(:,:,i)=single(tmp2);

end

this is the code if i mention yours code i got another error pl check he code if possible

Image Analyst on 13 Jan 2018

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/376990-i-am-getting-the-error-while-reading-the-images#comment_524378

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/376990-i-am-getting-the-error-while-reading-the-images#comment_524378

Now you've totally confused us. You've accepted the answer but then you've posted chunks of code in three different locations and say it's not solved. Please clarify. Edit or delete your other posts so you just have one response to me in one place.

Sign in to comment.

More Answers (2)

Pavan Kumar M.P on 13 Jan 2018

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/376990-i-am-getting-the-error-while-reading-the-images#answer_299989

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/376990-i-am-getting-the-error-while-reading-the-images#answer_299989

Open in MATLAB Online

function [pImg, pImg_rgb, sImg] = ... createTrainingData_color(ipDir, isDir, opFile, pSize)

addpath('utils/');

%ipDir='../Dataset/photos/'; %isDir='../Dataset/photos/';

files_p = dir([ipDir '*.jpg']); files_s = dir([isDir '*.jpg']);

%Find the nubmer files and the size of images

tmp1=imread([ipDir , files_p(1).name]); nFile = numel(files_p); [nRow, nCol, nCh] = size(tmp1);

%initialize matrix for data pImg_luv = zeros(nRow,nCol,nCh, nFile); pImg_rgb = zeros(nRow,nCol,nCh, nFile);

pImg = zeros(nRow,nCol,nFile); sImg = zeros(nRow,nCol,nFile); intImg = zeros(nRow,nCol,nFile); nRowPatch = nRow-pSize(1); nColPatch = nCol- pSize(2); squareSum = zeros(nRowPatch, nColPatch, nFile);

for i=1:nFile tmp1=imread([ipDir files_p(i).name]); pImg(:,:,i)=single(rgb2gray(tmp1));

pImg_rgb(:,:,:,i)= tmp1;

pImg_luv(:,:,:,i)= rgb2luv(tmp1);

intImg(:,:,i) = integralimage(pImg(:,:,i).^2);

%IRs

for m=1:nRowPatch

for n=1:nColPatch

squareSum(m,n,i)=intImg(m,n,i)+intImg(m+pSize(1)-1,n+pSize(2)-1,i)-intImg(m,n+pSize(2)-1,i)-intImg(m+pSize(1)-1,n,i);

end

end

tmp2=imread([isDir files_s(i).name]);

sImg(:,:,i)=single(tmp2);

end

save(opFile, 'pImg', 'pImg_rgb', 'pImg_luv', 'squareSum', 'sImg', 'files_p', 'files_s');

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Pavan Kumar M.P on 13 Jan 2018

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/376990-i-am-getting-the-error-while-reading-the-images#answer_299990

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/376990-i-am-getting-the-error-while-reading-the-images#answer_299990

Open in MATLAB Online

function [pImg, pImg_rgb, sImg] = ... createTrainingData_color(ipDir, isDir, opFile, pSize)

addpath('utils/');

%ipDir='../Dataset/photos/'; %isDir='../Dataset/photos/';

files_p = dir([ipDir '*.jpg']); files_s = dir([isDir '*.jpg']);

%Find the nubmer files and the size of images

tmp1=imread([ipDir , files_p(1).name]); nFile = numel(files_p); [nRow, nCol, nCh] = size(tmp1);

%initialize matrix for data pImg_luv = zeros(nRow,nCol,nCh, nFile); pImg_rgb = zeros(nRow,nCol,nCh, nFile);

pImg = zeros(nRow,nCol,nFile); sImg = zeros(nRow,nCol,nFile); intImg = zeros(nRow,nCol,nFile); nRowPatch = nRow-pSize(1); nColPatch = nCol- pSize(2); squareSum = zeros(nRowPatch, nColPatch, nFile);

for i=1:nFile tmp1=imread([ipDir files_p(i).name]); pImg(:,:,i)=single(rgb2gray(tmp1));

pImg_rgb(:,:,:,i)= tmp1;

pImg_luv(:,:,:,i)= rgb2luv(tmp1);

intImg(:,:,i) = integralimage(pImg(:,:,i).^2);

%IRs

for m=1:nRowPatch

for n=1:nColPatch

squareSum(m,n,i)=intImg(m,n,i)+intImg(m+pSize(1)-1,n+pSize(2)-1,i)-intImg(m,n+pSize(2)-1,i)-intImg(m+pSize(1)-1,n,i);

end

end

tmp2=imread([isDir files_s(i).name]);

sImg(:,:,i)=single(tmp2);

end

save(opFile, 'pImg', 'pImg_rgb', 'pImg_luv', 'squareSum', 'sImg', 'files_p', 'files_s');

this is the actual code i got the problem while reading the imaage by using imread(); pl help me

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

See Also

Categories

SciencesAgriculture

Find more on Agriculture in Help Center and File Exchange

Tags

  • err
  • image processing

Community Treasure Hunt

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

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


i am getting the error while reading the images (7)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • 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
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

i am getting the error while reading the images (2024)
Top Articles
Tissot T-Classic Women's Automatic Watch for AU$476 for sale from a Seller on Chrono24
No Cable Schedule
Melson Funeral Services Obituaries
Kansas City Kansas Public Schools Educational Audiology Externship in Kansas City, KS for KCK public Schools
What is Mercantilism?
Crossed Eyes (Strabismus): Symptoms, Causes, and Diagnosis
The Potter Enterprise from Coudersport, Pennsylvania
Fnv Turbo
ds. J.C. van Trigt - Lukas 23:42-43 - Preekaantekeningen
Concacaf Wiki
Imbigswoo
LeBron James comes out on fire, scores first 16 points for Cavaliers in Game 2 vs. Pacers
2021 Lexus IS for sale - Richardson, TX - craigslist
David Turner Evangelist Net Worth
Troy Athens Cheer Weebly
Guidewheel lands $9M Series A-1 for SaaS that boosts manufacturing and trims carbon emissions | TechCrunch
Apne Tv Co Com
Fsga Golf
Craigslist Personals Jonesboro
Www.patientnotebook/Atic
Reviews over Supersaver - Opiness - Spreekt uit ervaring
Inkwell, pen rests and nib boxes made of pewter, glass and porcelain.
پنل کاربری سایت همسریابی هلو
Airline Reception Meaning
Craig Woolard Net Worth
Masterbuilt Gravity Fan Not Working
Co10 Unr
Mchoul Funeral Home Of Fishkill Inc. Services
Ugly Daughter From Grown Ups
Ilabs Ucsf
Lil Durk's Brother DThang Killed in Harvey, Illinois, ME Confirms
Poster & 1600 Autocollants créatifs | Activité facile et ludique | Poppik Stickers
Serenity Of Lathrop - Manteca Photos
Watchdocumentaries Gun Mayhem 2
Domino's Delivery Pizza
Main Street Station Coshocton Menu
Lovein Funeral Obits
2 Pm Cdt
511Pa
Dinar Detectives Cracking the Code of the Iraqi Dinar Market
Giovanna Ewbank Nua
Academic Notice and Subject to Dismissal
Haunted Mansion (2023) | Rotten Tomatoes
Craigslist Houses For Rent Little River Sc
Lesson 5 Homework 4.5 Answer Key
Dineren en overnachten in Boutique Hotel The Church in Arnhem - Priya Loves Food & Travel
Otter Bustr
Raley Scrubs - Midtown
Metra Union Pacific West Schedule
Service Changes and Self-Service Options
Psalm 46 New International Version
Olay Holiday Gift Rebate.com
Latest Posts
Article information

Author: Sen. Ignacio Ratke

Last Updated:

Views: 5965

Rating: 4.6 / 5 (76 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Sen. Ignacio Ratke

Birthday: 1999-05-27

Address: Apt. 171 8116 Bailey Via, Roberthaven, GA 58289

Phone: +2585395768220

Job: Lead Liaison

Hobby: Lockpicking, LARPing, Lego building, Lapidary, Macrame, Book restoration, Bodybuilding

Introduction: My name is Sen. Ignacio Ratke, I am a adventurous, zealous, outstanding, agreeable, precious, excited, gifted person who loves writing and wants to share my knowledge and understanding with you.